|
|
|
|
@ -15,13 +15,11 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BottomSheetListGameFragment : BottomSheetFragment(), |
|
|
|
|
RowRepresentableDataSource, |
|
|
|
|
RowRepresentableDelegate { |
|
|
|
|
class BottomSheetListGameFragment : BottomSheetFragment(), RowRepresentableDataSource, RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
private var limit: Int = -1 |
|
|
|
|
private var realmData: RealmResults<*>? = null |
|
|
|
|
private lateinit var dataAdapter: RowRepresentableAdapter |
|
|
|
|
private val values = ArrayList<Any?>() |
|
|
|
|
@ -71,7 +69,7 @@ class BottomSheetListGameFragment : BottomSheetFragment(), |
|
|
|
|
val selectedData = it[position] |
|
|
|
|
selectedData?.let { data -> |
|
|
|
|
values[1] = data |
|
|
|
|
this.delegate.onRowValueChanged(data, row) |
|
|
|
|
this.delegate.onRowValueChanged(values, this.row) |
|
|
|
|
dismiss() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -84,6 +82,7 @@ class BottomSheetListGameFragment : BottomSheetFragment(), |
|
|
|
|
private fun initData() { |
|
|
|
|
val bottomSheetData = getData() |
|
|
|
|
if (bottomSheetData.isNotEmpty() && bottomSheetData.size >= 2 && bottomSheetData[1].data != null) { |
|
|
|
|
this.limit = bottomSheetData[0].defaultValue as Int? ?: -1 |
|
|
|
|
this.realmData = bottomSheetData[1].data as RealmResults<*> |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -95,7 +94,7 @@ class BottomSheetListGameFragment : BottomSheetFragment(), |
|
|
|
|
|
|
|
|
|
LayoutInflater.from(requireContext()).inflate(R.layout.bottom_sheet_game_list, view?.bottomSheetContainer, true) |
|
|
|
|
|
|
|
|
|
values.add(0, null) |
|
|
|
|
values.add(0, if (limit == -1) null else limit) |
|
|
|
|
values.add(1, null) |
|
|
|
|
|
|
|
|
|
chipGroup.removeAllViews() |
|
|
|
|
@ -103,11 +102,11 @@ class BottomSheetListGameFragment : BottomSheetFragment(), |
|
|
|
|
val chip = Chip(requireContext()) |
|
|
|
|
chip.text = it.shortName |
|
|
|
|
chip.id = it.ordinal |
|
|
|
|
chip.isChecked = it.ordinal == limit |
|
|
|
|
chipGroup.addView(chip) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
chipGroup.setOnCheckedChangeListener { _, i -> |
|
|
|
|
Timber.d("Chip selected: $i") |
|
|
|
|
values[0] = i |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|