commit
1f2bf80142
@ -0,0 +1,60 @@ |
|||||||
|
package net.pokeranalytics.android.ui.activity |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.content.Intent |
||||||
|
import android.os.Bundle |
||||||
|
import androidx.fragment.app.Fragment |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||||
|
import net.pokeranalytics.android.ui.fragment.FilterDetailsFragment |
||||||
|
|
||||||
|
class FilterDetailsActivity : PokerAnalyticsActivity() { |
||||||
|
|
||||||
|
enum class IntentKey(val keyName: String) { |
||||||
|
FILTER_CATEGORY_ORDINAL("FILTER_CATEGORY_ORDINAL") |
||||||
|
} |
||||||
|
|
||||||
|
companion object { |
||||||
|
/** |
||||||
|
* Default constructor |
||||||
|
*/ |
||||||
|
fun newInstance(context: Context, filterCategoryOrdinal: Int) { |
||||||
|
val intent = Intent(context, FilterDetailsActivity::class.java) |
||||||
|
intent.putExtra(IntentKey.FILTER_CATEGORY_ORDINAL.keyName, filterCategoryOrdinal) |
||||||
|
context.startActivity(intent) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new instance for result |
||||||
|
*/ |
||||||
|
fun newInstanceForResult(fragment: Fragment, filterCategoryOrdinal: Int, requestCode: Int) { |
||||||
|
val intent = Intent(fragment.requireContext(), FilterDetailsActivity::class.java) |
||||||
|
intent.putExtra(IntentKey.FILTER_CATEGORY_ORDINAL.keyName, filterCategoryOrdinal) |
||||||
|
fragment.startActivityForResult(intent, requestCode) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) { |
||||||
|
super.onCreate(savedInstanceState) |
||||||
|
setContentView(R.layout.activity_filter_details) |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
val fragmentManager = supportFragmentManager |
||||||
|
val fragmentTransaction = fragmentManager.beginTransaction() |
||||||
|
val filterCategoryOrdinal = intent.getIntExtra(IntentKey.FILTER_CATEGORY_ORDINAL.keyName, 0) |
||||||
|
|
||||||
|
val fragment = FilterDetailsFragment() |
||||||
|
fragmentTransaction.add(R.id.container, fragment) |
||||||
|
fragmentTransaction.commit() |
||||||
|
fragment.setData(filterCategoryOrdinal) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,245 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment |
||||||
|
|
||||||
|
import android.os.Bundle |
||||||
|
import android.view.* |
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager |
||||||
|
import io.realm.RealmObject |
||||||
|
import kotlinx.android.synthetic.main.fragment_filter_details.* |
||||||
|
import kotlinx.android.synthetic.main.fragment_filter_details.view.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
||||||
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterCategoryRow |
||||||
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSubcategoryRow |
||||||
|
import timber.log.Timber |
||||||
|
|
||||||
|
|
||||||
|
open class FilterDetailsFragment : PokerAnalyticsFragment(), RowRepresentableDataSource, RowRepresentableDelegate { |
||||||
|
|
||||||
|
lateinit var parentActivity: PokerAnalyticsActivity |
||||||
|
lateinit var item: RealmObject |
||||||
|
lateinit var rowRepresentableAdapter: RowRepresentableAdapter |
||||||
|
|
||||||
|
|
||||||
|
private var rows: ArrayList<RowRepresentable> = ArrayList() |
||||||
|
private var filterMenu: Menu? = null |
||||||
|
private var filterCategory: FilterCategoryRow? = null |
||||||
|
|
||||||
|
var isUpdating = false |
||||||
|
var shouldOpenKeyboard = true |
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
||||||
|
return inflater.inflate(R.layout.fragment_filter_details, container, false) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||||
|
super.onViewCreated(view, savedInstanceState) |
||||||
|
initUI() |
||||||
|
initData() |
||||||
|
} |
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { |
||||||
|
/* |
||||||
|
inflater?.inflate(R.menu.editable_data, menu) |
||||||
|
this.filterMenu = menu |
||||||
|
*/ |
||||||
|
updateMenuUI() |
||||||
|
super.onCreateOptionsMenu(menu, inflater) |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem?): Boolean { |
||||||
|
when (item!!.itemId) { |
||||||
|
R.id.save -> saveData() |
||||||
|
R.id.delete -> deleteData() |
||||||
|
} |
||||||
|
return true |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
||||||
|
super.onRowSelected(position, row, fromAction) |
||||||
|
|
||||||
|
|
||||||
|
filterCategory?.let { |
||||||
|
for (subcategory in it.getSubcategories()) { |
||||||
|
if (subcategory.getFilterRows(getRealm()).contains(row)) { |
||||||
|
if (subcategory.getType() == FilterSubcategoryRow.Type.SINGLE) { |
||||||
|
for (filterRow in subcategory.getFilterRows(getRealm())) { |
||||||
|
selectedRows.remove(filterRow) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (selectedRows.contains(row)) { |
||||||
|
selectedRows.remove(row) |
||||||
|
} else { |
||||||
|
selectedRows.add(row) |
||||||
|
} |
||||||
|
|
||||||
|
rowRepresentableAdapter.notifyDataSetChanged() |
||||||
|
} |
||||||
|
|
||||||
|
val selectedRows = ArrayList<RowRepresentable>() |
||||||
|
|
||||||
|
override fun isSelected(row: RowRepresentable): Boolean { |
||||||
|
return selectedRows.contains(row) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
||||||
|
super.onRowValueChanged(value, row) |
||||||
|
} |
||||||
|
|
||||||
|
override fun adapterRows(): List<RowRepresentable>? { |
||||||
|
return rows |
||||||
|
} |
||||||
|
|
||||||
|
override fun rowRepresentableForPosition(position: Int): RowRepresentable? { |
||||||
|
return rows[position] |
||||||
|
} |
||||||
|
|
||||||
|
override fun numberOfRows(): Int { |
||||||
|
return rows.size |
||||||
|
} |
||||||
|
|
||||||
|
override fun viewTypeForPosition(position: Int): Int { |
||||||
|
val rowViewType = rowRepresentableForPosition(position)?.viewType ?: -1 |
||||||
|
return if (rowViewType != -1) rowViewType else RowViewType.TITLE_CHECK.ordinal |
||||||
|
} |
||||||
|
|
||||||
|
override fun indexForRow(row: RowRepresentable): Int { |
||||||
|
return rows.indexOf(row) |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
parentActivity = activity as PokerAnalyticsActivity |
||||||
|
parentActivity.setSupportActionBar(toolbar) |
||||||
|
parentActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
||||||
|
setHasOptionsMenu(true) |
||||||
|
|
||||||
|
val viewManager = LinearLayoutManager(requireContext()) |
||||||
|
|
||||||
|
recyclerView.apply { |
||||||
|
setHasFixedSize(true) |
||||||
|
layoutManager = viewManager |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init data |
||||||
|
*/ |
||||||
|
private fun initData() { |
||||||
|
|
||||||
|
Timber.d("initData") |
||||||
|
|
||||||
|
this.appBar.toolbar.title = getString(R.string.filter) |
||||||
|
|
||||||
|
filterCategory?.let { |
||||||
|
|
||||||
|
this.appBar.toolbar.title = it.localizedTitle(requireContext()) |
||||||
|
|
||||||
|
this.rows.clear() |
||||||
|
for (subcategory in it.getSubcategories()) { |
||||||
|
this.rows.add(subcategory) |
||||||
|
this.rows.addAll(subcategory.getFilterRows(getRealm())) |
||||||
|
} |
||||||
|
|
||||||
|
this.rowRepresentableAdapter = RowRepresentableAdapter(this, this) |
||||||
|
this.recyclerView.adapter = rowRepresentableAdapter |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update menu UI |
||||||
|
*/ |
||||||
|
private fun updateMenuUI() { |
||||||
|
/* |
||||||
|
editableMenu?.findItem(R.id.delete)?.isVisible = isUpdating |
||||||
|
editableMenu?.findItem(R.id.save)?.isVisible = true |
||||||
|
*/ |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Save data |
||||||
|
*/ |
||||||
|
fun saveData() { |
||||||
|
/* |
||||||
|
if ((this.item as Savable).isValidForSave()) { |
||||||
|
this.getRealm().executeTransaction { |
||||||
|
val item = it.copyToRealmOrUpdate(this.item) |
||||||
|
|
||||||
|
val uniqueIdentifier = if (item is Identifiable) { |
||||||
|
item.id |
||||||
|
} else "" |
||||||
|
|
||||||
|
finishActivityWithResult(uniqueIdentifier) |
||||||
|
} |
||||||
|
} else { |
||||||
|
val message = (this.item as Savable).getFailedSaveMessage() |
||||||
|
val builder = AlertDialog.Builder(requireContext()) |
||||||
|
.setMessage(message) |
||||||
|
.setNegativeButton(R.string.ok, null) |
||||||
|
builder.show() |
||||||
|
} |
||||||
|
*/ |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Delete data |
||||||
|
*/ |
||||||
|
private fun deleteData() { |
||||||
|
/* |
||||||
|
val builder = AlertDialog.Builder(requireContext()) |
||||||
|
builder.setTitle(R.string.warning) |
||||||
|
.setMessage(R.string.are_you_sure_you_want_to_do_that_) |
||||||
|
.setNegativeButton(R.string.no, null) |
||||||
|
.setPositiveButton(R.string.yes) { _, _ -> |
||||||
|
//TODO: Maybe update this code, does the object need to be managed? |
||||||
|
this.getRealm().executeTransaction { |
||||||
|
this.liveDataType.deleteData(it, (this.item as Manageable)) |
||||||
|
} |
||||||
|
this.activity?.finish() |
||||||
|
} |
||||||
|
builder.show() |
||||||
|
*/ |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Finish the activity with a result |
||||||
|
*/ |
||||||
|
private fun finishActivityWithResult(uniqueIdentifier: String) { |
||||||
|
/* |
||||||
|
val intent = Intent() |
||||||
|
intent.putExtra(EditableDataActivity.IntentKey.DATA_TYPE.keyName, dataType) |
||||||
|
intent.putExtra(EditableDataActivity.IntentKey.PRIMARY_KEY.keyName, uniqueIdentifier) |
||||||
|
activity?.setResult(RESULT_OK, intent) |
||||||
|
*/ |
||||||
|
activity?.finish() |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set fragment data |
||||||
|
*/ |
||||||
|
fun setData(filterCategory: Int) { |
||||||
|
|
||||||
|
this.filterCategory = FilterCategoryRow.values()[filterCategory] |
||||||
|
|
||||||
|
/* |
||||||
|
this.dataType = dataType |
||||||
|
this.liveDataType = LiveData.values()[dataType] |
||||||
|
this.primaryKey = primaryKey |
||||||
|
*/ |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,91 @@ |
|||||||
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
||||||
|
|
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
|
||||||
|
enum class FilterCategoryRow : RowRepresentable { |
||||||
|
|
||||||
|
GENERAL, |
||||||
|
DATE, |
||||||
|
DURATION, |
||||||
|
SESSION, |
||||||
|
CASH, |
||||||
|
TOURNAMENT, |
||||||
|
ONLINE, |
||||||
|
RESULT, |
||||||
|
TRANSACTION_TYPES, |
||||||
|
|
||||||
|
// Title Custom fields |
||||||
|
LOCATION, |
||||||
|
BANKROLL, |
||||||
|
PLAYERS; |
||||||
|
|
||||||
|
override val resId: Int? |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
GENERAL -> R.string.general |
||||||
|
DATE -> R.string.date |
||||||
|
DURATION -> R.string.duration |
||||||
|
SESSION -> R.string.session |
||||||
|
CASH -> R.string.cash |
||||||
|
TOURNAMENT -> R.string.tournament |
||||||
|
ONLINE -> R.string.online |
||||||
|
RESULT -> R.string.result |
||||||
|
TRANSACTION_TYPES -> R.string.operation_types |
||||||
|
LOCATION -> R.string.location |
||||||
|
BANKROLL -> R.string.bankroll |
||||||
|
PLAYERS -> R.string.players |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val viewType: Int |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
GENERAL, DATE, DURATION, SESSION, CASH, TOURNAMENT, ONLINE, RESULT, TRANSACTION_TYPES, |
||||||
|
LOCATION, BANKROLL, PLAYERS -> RowViewType.TITLE_VALUE_ARROW.ordinal |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get subcategories of filters |
||||||
|
*/ |
||||||
|
fun getSubcategories(): ArrayList<FilterSubcategoryRow> { |
||||||
|
val subcategories = ArrayList<FilterSubcategoryRow>() |
||||||
|
|
||||||
|
when (this) { |
||||||
|
GENERAL -> subcategories.addAll( |
||||||
|
arrayListOf( |
||||||
|
FilterSubcategoryRow.CASH_TOURNAMENT, FilterSubcategoryRow.LIVE_ONLINE, FilterSubcategoryRow.GAME, |
||||||
|
FilterSubcategoryRow.LIMIT_TYPE, FilterSubcategoryRow.TABLE_SIZE |
||||||
|
) |
||||||
|
) |
||||||
|
DATE -> subcategories.addAll( |
||||||
|
arrayListOf( |
||||||
|
FilterSubcategoryRow.DYNAMIC_DATE, FilterSubcategoryRow.FIXED_DATE, FilterSubcategoryRow.DURATION, FilterSubcategoryRow.YEAR, |
||||||
|
FilterSubcategoryRow.WEEKDAYS_OR_WEEKEND, FilterSubcategoryRow.DAY_OF_WEEK, FilterSubcategoryRow.MONTH_OF_YEAR |
||||||
|
) |
||||||
|
) |
||||||
|
DURATION -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.SESSION_DURATION, FilterSubcategoryRow.RANGE)) |
||||||
|
SESSION -> subcategories.addAll(arrayListOf()) |
||||||
|
CASH -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.BLINDS, FilterSubcategoryRow.CASH_RE_BUY_COUNT)) |
||||||
|
TOURNAMENT -> subcategories.addAll( |
||||||
|
arrayListOf( |
||||||
|
FilterSubcategoryRow.TOURNAMENT_TYPE, FilterSubcategoryRow.COMPLETION_PERCENTAGE, FilterSubcategoryRow.PLACE, |
||||||
|
FilterSubcategoryRow.PLAYERS_COUNT, FilterSubcategoryRow.TOURNAMENT_RE_BUY_COUNT, FilterSubcategoryRow.BUY_IN |
||||||
|
) |
||||||
|
) |
||||||
|
ONLINE -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.MULTI_TABLING)) |
||||||
|
RESULT -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.VALUE)) |
||||||
|
TRANSACTION_TYPES -> subcategories.addAll(arrayListOf()) |
||||||
|
LOCATION -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.LOCATION)) |
||||||
|
BANKROLL -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.BANKROLL)) |
||||||
|
PLAYERS -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.NUMBER_OF_PLAYERS, FilterSubcategoryRow.MULTI_PLAYER)) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
return subcategories |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,146 @@ |
|||||||
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
||||||
|
|
||||||
|
import io.realm.Realm |
||||||
|
import io.realm.RealmResults |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.Limit |
||||||
|
import net.pokeranalytics.android.model.LiveData |
||||||
|
import net.pokeranalytics.android.model.realm.Game |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
|
||||||
|
enum class FilterSubcategoryRow : RowRepresentable { |
||||||
|
|
||||||
|
// General |
||||||
|
CASH_TOURNAMENT, |
||||||
|
LIVE_ONLINE, |
||||||
|
GAME, |
||||||
|
LIMIT_TYPE, |
||||||
|
TABLE_SIZE, |
||||||
|
|
||||||
|
// Date |
||||||
|
DYNAMIC_DATE, |
||||||
|
FIXED_DATE, |
||||||
|
DURATION, |
||||||
|
YEAR, |
||||||
|
WEEKDAYS_OR_WEEKEND, |
||||||
|
DAY_OF_WEEK, |
||||||
|
MONTH_OF_YEAR, |
||||||
|
|
||||||
|
// Duration |
||||||
|
SESSION_DURATION, |
||||||
|
RANGE, |
||||||
|
|
||||||
|
// Sessions |
||||||
|
// - |
||||||
|
|
||||||
|
// Cash |
||||||
|
BLINDS, |
||||||
|
CASH_RE_BUY_COUNT, |
||||||
|
|
||||||
|
// Tournament |
||||||
|
TOURNAMENT_TYPE, |
||||||
|
COMPLETION_PERCENTAGE, |
||||||
|
PLACE, |
||||||
|
PLAYERS_COUNT, |
||||||
|
TOURNAMENT_RE_BUY_COUNT, |
||||||
|
BUY_IN, |
||||||
|
|
||||||
|
// Online |
||||||
|
MULTI_TABLING, |
||||||
|
|
||||||
|
// Result |
||||||
|
VALUE, |
||||||
|
|
||||||
|
// Transaction types |
||||||
|
// - |
||||||
|
|
||||||
|
// Location |
||||||
|
LOCATION, |
||||||
|
|
||||||
|
// Bankroll |
||||||
|
BANKROLL, |
||||||
|
|
||||||
|
// Players |
||||||
|
NUMBER_OF_PLAYERS, |
||||||
|
MULTI_PLAYER; |
||||||
|
|
||||||
|
enum class Type { |
||||||
|
SINGLE, |
||||||
|
MULTIPLE, |
||||||
|
} |
||||||
|
|
||||||
|
override val resId: Int? |
||||||
|
get() { |
||||||
|
return when(this) { |
||||||
|
CASH_TOURNAMENT -> R.string.cash_or_tournament |
||||||
|
LIVE_ONLINE -> R.string.live_or_online |
||||||
|
GAME -> R.string.game |
||||||
|
LIMIT_TYPE -> R.string.type_de_limite |
||||||
|
TABLE_SIZE -> R.string.table_size |
||||||
|
|
||||||
|
DYNAMIC_DATE -> R.string.dynamic_date |
||||||
|
FIXED_DATE -> R.string.fixed_date |
||||||
|
DURATION -> R.string.duration |
||||||
|
YEAR -> R.string.year |
||||||
|
WEEKDAYS_OR_WEEKEND -> R.string.weekdays_or_weekend |
||||||
|
DAY_OF_WEEK -> R.string.day_of_the_week |
||||||
|
MONTH_OF_YEAR -> R.string.month_of_the_year |
||||||
|
|
||||||
|
SESSION_DURATION -> R.string.session_duration |
||||||
|
RANGE -> R.string.hour_slot |
||||||
|
|
||||||
|
BLINDS -> R.string.blinds |
||||||
|
CASH_RE_BUY_COUNT -> R.string.rebuy_count |
||||||
|
|
||||||
|
TOURNAMENT_TYPE -> R.string.tournament_type |
||||||
|
COMPLETION_PERCENTAGE -> R.string.tournament_completion_percentage_interval |
||||||
|
PLACE -> R.string.place |
||||||
|
PLAYERS_COUNT -> R.string.players_count |
||||||
|
TOURNAMENT_RE_BUY_COUNT -> R.string.rebuy_count |
||||||
|
BUY_IN -> R.string.buyin |
||||||
|
|
||||||
|
MULTI_TABLING -> R.string.multi_tabling |
||||||
|
|
||||||
|
VALUE -> R.string.value |
||||||
|
|
||||||
|
LOCATION -> R.string.location |
||||||
|
|
||||||
|
BANKROLL -> R.string.bankroll |
||||||
|
|
||||||
|
NUMBER_OF_PLAYERS -> R.string.number_of_players |
||||||
|
MULTI_PLAYER -> R.string.multiplayer |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val viewType: Int = RowViewType.CLASSIC_HEADER_TITLE.ordinal |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the type of the selection |
||||||
|
*/ |
||||||
|
fun getType() : Type { |
||||||
|
return when(this) { |
||||||
|
GAME -> Type.MULTIPLE |
||||||
|
else -> Type.SINGLE |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the filter rows |
||||||
|
*/ |
||||||
|
fun getFilterRows(realm: Realm) : ArrayList<RowRepresentable> { |
||||||
|
val rows = ArrayList<RowRepresentable>() |
||||||
|
when(this) { |
||||||
|
CASH_TOURNAMENT -> rows.addAll(arrayListOf(FilterRow.CASH_GAME, FilterRow.TOURNAMENT)) |
||||||
|
LIVE_ONLINE -> rows.addAll(arrayListOf(FilterRow.LIVE, FilterRow.ONLINE)) |
||||||
|
GAME -> { |
||||||
|
val games = realm.copyFromRealm(LiveData.GAME.items(realm) as RealmResults<Game>) |
||||||
|
rows.addAll(games) |
||||||
|
} |
||||||
|
LIMIT_TYPE -> rows.addAll(Limit.values()) |
||||||
|
else -> rows.addAll(arrayListOf()) |
||||||
|
} |
||||||
|
return rows |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:id="@+id/container" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
</FrameLayout> |
||||||
@ -0,0 +1,61 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView |
||||||
|
android:id="@+id/nestedScrollView" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:fillViewport="true" |
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"> |
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content"> |
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView |
||||||
|
android:id="@+id/recyclerView" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="0dp" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView> |
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout |
||||||
|
android:id="@+id/appBar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="128dp" |
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> |
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout |
||||||
|
android:id="@+id/collapsingToolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
app:collapsedTitleTextAppearance="@style/PokerAnalyticsTheme.Toolbar.CollapsedTitleAppearance" |
||||||
|
app:contentScrim="?attr/colorPrimary" |
||||||
|
app:expandedTitleGravity="bottom" |
||||||
|
app:expandedTitleMarginStart="72dp" |
||||||
|
app:expandedTitleTextAppearance="@style/PokerAnalyticsTheme.Toolbar.ExpandedTitleAppearance" |
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> |
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?attr/actionBarSize" |
||||||
|
app:layout_collapseMode="pin" |
||||||
|
app:title="Poker Analytics" |
||||||
|
app:titleTextColor="@color/white" /> |
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout> |
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout> |
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
||||||
Loading…
Reference in new issue