Fixes multiselection issue

dev
Laurent 7 years ago
parent 16688a9fd9
commit c598211c15
  1. 2
      app/src/main/java/net/pokeranalytics/android/PokerAnalyticsApplication.kt
  2. 3
      app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt
  3. 8
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetListFragment.kt
  4. 5
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetListGameFragment.kt
  5. 3
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetMultiSelectionFragment.kt
  6. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/RowRepresentableEditDescriptor.kt
  7. 4
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/SessionRow.kt
  8. 4
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/TransactionRow.kt

@ -61,7 +61,7 @@ class PokerAnalyticsApplication : Application() {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Timber.d("UserPreferences.defaultCurrency: ${UserDefaults.currency.symbol}") Timber.d("UserPreferences.defaultCurrency: ${UserDefaults.currency.symbol}")
this.createFakeSessions() // this.createFakeSessions()
} }

@ -55,7 +55,8 @@ class RowRepresentableAdapter(
return return
} }
val index = this.dataSource.adapterRows()?.indexOf(row) ?: -1 val rows = this.dataSource.adapterRows()
val index = rows?.indexOf(row) ?: -1
if (index >= 0) { if (index >= 0) {
notifyItemChanged(index) notifyItemChanged(index)
} }

@ -18,7 +18,11 @@ import net.pokeranalytics.android.ui.view.RowViewType
open class BottomSheetListFragment : BottomSheetFragment(), LiveRowRepresentableDataSource, RowRepresentableDelegate { open class BottomSheetListFragment : BottomSheetFragment(), LiveRowRepresentableDataSource, RowRepresentableDelegate {
lateinit var dataAdapter: RowRepresentableAdapter lateinit var dataAdapter: RowRepresentableAdapter
var realmData: RealmResults<*>? = null var realmData: RealmResults<RowRepresentable>? = null
override fun adapterRows(): List<RowRepresentable>? {
return this.realmData
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@ -71,7 +75,7 @@ open class BottomSheetListFragment : BottomSheetFragment(), LiveRowRepresentable
if (bottomSheetData.first().data == null) { if (bottomSheetData.first().data == null) {
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency") throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency")
} }
this.realmData = bottomSheetData.first().data as RealmResults<*> this.realmData = bottomSheetData.first().data as RealmResults<RowRepresentable>
} }
/** /**

@ -6,15 +6,14 @@ import android.view.View
import androidx.core.view.get import androidx.core.view.get
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
import io.realm.RealmResults
import kotlinx.android.synthetic.main.bottom_sheet_game_list.* import kotlinx.android.synthetic.main.bottom_sheet_game_list.*
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.*
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException
import net.pokeranalytics.android.model.Limit import net.pokeranalytics.android.model.Limit
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.extensions.px import net.pokeranalytics.android.ui.extensions.px
import net.pokeranalytics.android.ui.view.RowRepresentable
/** /**
* Bottom Sheet List Game Fragment * Bottom Sheet List Game Fragment
@ -58,7 +57,7 @@ class BottomSheetListGameFragment : BottomSheetListFragment() {
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency") throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency")
} }
this.limit = bottomSheetData[0].defaultValue as Int? this.limit = bottomSheetData[0].defaultValue as Int?
this.realmData = bottomSheetData[1].data as RealmResults<*> this.realmData = bottomSheetData[1].data
} }
/** /**

@ -53,7 +53,8 @@ open class BottomSheetMultiSelectionFragment : BottomSheetListFragment() {
override fun initData() { override fun initData() {
super.initData() super.initData()
val bottomSheetData = getData()?:throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found") val bottomSheetData =
getData() ?: throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found")
if (bottomSheetData.size != 1) { if (bottomSheetData.size != 1) {
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency") throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency")
} }

@ -9,6 +9,6 @@ class RowRepresentableEditDescriptor(
var defaultValue: Any? = null, var defaultValue: Any? = null,
var hint: Int? = null, var hint: Int? = null,
var inputType: Int? = null, var inputType: Int? = null,
var data: RealmResults<*>? = null, var data: RealmResults<RowRepresentable>? = null,
var staticData: List<RowRepresentable>? = null var staticData: List<RowRepresentable>? = null
) )

@ -255,7 +255,7 @@ enum class SessionRow : RowRepresentable {
GAME -> { GAME -> {
val limit: Int? by map val limit: Int? by map
val defaultValue: Any? by map val defaultValue: Any? by map
val data: RealmResults<*>? by map val data: RealmResults<RowRepresentable>? by map
arrayListOf( arrayListOf(
RowRepresentableEditDescriptor(limit), RowRepresentableEditDescriptor(limit),
RowRepresentableEditDescriptor(defaultValue, data = data) RowRepresentableEditDescriptor(defaultValue, data = data)
@ -269,7 +269,7 @@ enum class SessionRow : RowRepresentable {
} }
BANKROLL, LOCATION, TOURNAMENT_FEATURE, TOURNAMENT_NAME -> { BANKROLL, LOCATION, TOURNAMENT_FEATURE, TOURNAMENT_NAME -> {
val defaultValue: Any? by map val defaultValue: Any? by map
val data: RealmResults<*>? by map val data: RealmResults<RowRepresentable>? by map
arrayListOf( arrayListOf(
RowRepresentableEditDescriptor(defaultValue, data = data) RowRepresentableEditDescriptor(defaultValue, data = data)
) )

@ -54,14 +54,14 @@ enum class TransactionRow : RowRepresentable, DefaultEditDataSource {
return when (this) { return when (this) {
BANKROLL -> { BANKROLL -> {
val defaultValue : Any? by map val defaultValue : Any? by map
val data : RealmResults<*>? by map val data : RealmResults<RowRepresentable>? by map
arrayListOf( arrayListOf(
RowRepresentableEditDescriptor(defaultValue, data = data) RowRepresentableEditDescriptor(defaultValue, data = data)
) )
} }
TYPE -> { TYPE -> {
val defaultValue : Any? by map val defaultValue : Any? by map
val data : RealmResults<*>? by map val data : RealmResults<RowRepresentable>? by map
arrayListOf( arrayListOf(
RowRepresentableEditDescriptor(defaultValue, data = data) RowRepresentableEditDescriptor(defaultValue, data = data)
) )

Loading…
Cancel
Save