|
|
|
|
@ -9,15 +9,16 @@ 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.adapter.StaticRowRepresentableDataSource |
|
|
|
|
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 timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate { |
|
|
|
|
open class FilterDetailsFragment : PokerAnalyticsFragment(), RowRepresentableDataSource, RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
|
lateinit var item: RealmObject |
|
|
|
|
@ -59,10 +60,7 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
|
return rows |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
|
super.onRowSelected(position, row, fromAction) |
|
|
|
|
} |
|
|
|
|
@ -70,6 +68,29 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
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 |
|
|
|
|
@ -102,40 +123,15 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
this.appBar.toolbar.title = it.localizedTitle(requireContext()) |
|
|
|
|
|
|
|
|
|
this.rows.clear() |
|
|
|
|
this.rows.addAll(it.getSubcategories()) |
|
|
|
|
Timber.d("initData: ${this.rows.size}") |
|
|
|
|
for (subcategory in it.getSubcategories()) { |
|
|
|
|
this.rows.add(subcategory) |
|
|
|
|
this.rows.addAll(subcategory.getFilterRows(getRealm())) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.rowRepresentableAdapter = RowRepresentableAdapter(this, this) |
|
|
|
|
this.recyclerView.adapter = rowRepresentableAdapter |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
if (this.dataType != null) { |
|
|
|
|
val proxyItem: RealmObject? = this.liveDataType.getData(this.getRealm(), primaryKey) |
|
|
|
|
proxyItem?.let { |
|
|
|
|
//TODO: Localize |
|
|
|
|
this.appBar.toolbar.title = "Update ${this.liveDataType.localizedTitle(this.parentActivity).toLowerCase().capitalize()}" |
|
|
|
|
isUpdating = true |
|
|
|
|
} ?: run { |
|
|
|
|
//TODO: Localize |
|
|
|
|
this.appBar.toolbar.title = this.liveDataType.newEntityLocalizedTitle(requireContext()) |
|
|
|
|
} |
|
|
|
|
this.item = this.liveDataType.updateOrCreate(this.getRealm(), primaryKey) |
|
|
|
|
|
|
|
|
|
val dataSource = getDataSource() |
|
|
|
|
this.rowRepresentableAdapter = RowRepresentableAdapter(getDataSource(), this) |
|
|
|
|
this.recyclerView.adapter = rowRepresentableAdapter |
|
|
|
|
|
|
|
|
|
// When creating an object, open automatically the keyboard for the first row |
|
|
|
|
if (!isUpdating && shouldOpenKeyboard) { |
|
|
|
|
val row = dataSource.adapterRows()?.firstOrNull() |
|
|
|
|
row?.let { |
|
|
|
|
onRowSelected(0, it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -211,8 +207,6 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta |
|
|
|
|
*/ |
|
|
|
|
fun setData(filterCategory: Int) { |
|
|
|
|
|
|
|
|
|
Timber.d("Filter Category: ${FilterCategoryRow.values()[filterCategory]}") |
|
|
|
|
Timber.d("Filter Subcategories: ${FilterCategoryRow.values()[filterCategory].getSubcategories()}") |
|
|
|
|
this.filterCategory = FilterCategoryRow.values()[filterCategory] |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|