-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI elements should be laid out correctly, but none of the logic is in…
… place. Started working on the crypt class.
- Loading branch information
Showing
18 changed files
with
549 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
BlckchnMsg/app/src/main/java/io/github/romulus10/blckchnmsg/ListKeysFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package io.github.romulus10.blckchnmsg | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.support.v4.app.Fragment | ||
import android.support.v7.widget.GridLayoutManager | ||
import android.support.v7.widget.LinearLayoutManager | ||
import android.support.v7.widget.RecyclerView | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import io.github.romulus10.blckchnmsg.blckchnmsg.data.Key | ||
|
||
/** | ||
* A fragment representing a list of Items. | ||
* Activities containing this fragment MUST implement the | ||
* [ListKeysFragment.OnListFragmentInteractionListener] interface. | ||
*/ | ||
class ListKeysFragment : Fragment() { | ||
|
||
// TODO: Customize parameters | ||
private var columnCount = 1 | ||
|
||
private var listener: OnListFragmentInteractionListener? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
arguments?.let { | ||
columnCount = it.getInt(ARG_COLUMN_COUNT) | ||
} | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
val view = inflater.inflate(R.layout.fragment_listkeys_list, container, false) | ||
|
||
// Set the adapter | ||
if (view is RecyclerView) { | ||
with(view) { | ||
layoutManager = when { | ||
columnCount <= 1 -> LinearLayoutManager(context) | ||
else -> GridLayoutManager(context, columnCount) | ||
} | ||
adapter = MyListKeysRecyclerViewAdapter(Key.ITEMS, listener) | ||
} | ||
} | ||
return view | ||
} | ||
|
||
override fun onAttach(context: Context) { | ||
super.onAttach(context) | ||
if (context is OnListFragmentInteractionListener) { | ||
listener = context | ||
} else { | ||
throw RuntimeException(context.toString() + " must implement OnListFragmentInteractionListener") | ||
} | ||
} | ||
|
||
override fun onDetach() { | ||
super.onDetach() | ||
listener = null | ||
} | ||
|
||
/** | ||
* This interface must be implemented by activities that contain this | ||
* fragment to allow an interaction in this fragment to be communicated | ||
* to the activity and potentially other fragments contained in that | ||
* activity. | ||
* | ||
* | ||
* See the Android Training lesson | ||
* [Communicating with Other Fragments](http://developer.android.com/training/basics/fragments/communicating.html) | ||
* for more information. | ||
*/ | ||
interface OnListFragmentInteractionListener { | ||
// TODO: Update argument type and name | ||
fun onListFragmentInteraction(item: Key.Key) | ||
} | ||
|
||
companion object { | ||
|
||
// TODO: Customize parameter argument names | ||
const val ARG_COLUMN_COUNT = "column-count" | ||
|
||
// TODO: Customize parameter initialization | ||
@JvmStatic | ||
fun newInstance(columnCount: Int) = | ||
ListKeysFragment().apply { | ||
arguments = Bundle().apply { | ||
putInt(ARG_COLUMN_COUNT, columnCount) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
BlckchnMsg/app/src/main/java/io/github/romulus10/blckchnmsg/MyListKeysRecyclerViewAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package io.github.romulus10.blckchnmsg | ||
|
||
import android.support.v7.widget.RecyclerView | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
|
||
|
||
import io.github.romulus10.blckchnmsg.ListKeysFragment.OnListFragmentInteractionListener | ||
import io.github.romulus10.blckchnmsg.blckchnmsg.data.Key | ||
|
||
import kotlinx.android.synthetic.main.fragment_listkeys.view.* | ||
|
||
/** | ||
* [RecyclerView.Adapter] that can display a [DummyItem] and makes a call to the | ||
* specified [OnListFragmentInteractionListener]. | ||
* TODO: Replace the implementation with code for your data type. | ||
*/ | ||
class MyListKeysRecyclerViewAdapter( | ||
private val mValues: List<Key.Key>, | ||
private val mListener: OnListFragmentInteractionListener?) | ||
: RecyclerView.Adapter<MyListKeysRecyclerViewAdapter.ViewHolder>() { | ||
|
||
private val mOnClickListener: View.OnClickListener | ||
|
||
init { | ||
mOnClickListener = View.OnClickListener { v -> | ||
val item = v.tag as Key.Key | ||
// Notify the active callbacks interface (the activity, if the fragment is attached to | ||
// one) that an item has been selected. | ||
mListener?.onListFragmentInteraction(item) | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val view = LayoutInflater.from(parent.context) | ||
.inflate(R.layout.fragment_listkeys, parent, false) | ||
return ViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
val item = mValues[position] | ||
holder.mIdView.text = item.id | ||
holder.mContentView.text = item.content | ||
|
||
with(holder.mView) { | ||
tag = item | ||
setOnClickListener(mOnClickListener) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int = mValues.size | ||
|
||
inner class ViewHolder(val mView: View) : RecyclerView.ViewHolder(mView) { | ||
val mIdView: TextView = mView.item_number | ||
val mContentView: TextView = mView.content | ||
|
||
override fun toString(): String { | ||
return super.toString() + " '" + mContentView.text + "'" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.