Fixes crash occuring when setting player setups

blinds
Laurent 5 years ago
parent 2a49f831ea
commit 02ba62654f
  1. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt
  2. 9
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorFragment.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/EditorViewModel.kt

@ -619,7 +619,7 @@ open class HandHistory : RealmObject(), Deletable, RowRepresentable, Filterable,
}
// Check who has best score (EvaluatorBridge gives a lowest score for a better hand)
return results.min()?.let { best ->
return results.minOrNull()?.let { best ->
val winners = mutableListOf<Int>()
results.forEachIndexed { index, i ->
if (i == best && i != Int.MAX_VALUE) {

@ -68,6 +68,8 @@ class EditorFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListen
return this.model.isEdited
}
private var isKeyboardShown: Boolean = false
private var _binding: FragmentHandHistoryBinding? = null
private val binding get() = _binding!!
@ -467,7 +469,7 @@ class EditorFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListen
}
HandRowType.PLAYER_POSITION -> {
this.model.createPlayerSetupForPosition(value as Position)
this.editorAdapter.notifyDataSetChanged()
// this.editorAdapter.notifyDataSetChanged()
}
is ComputedAction -> {
this.model.amountChanged(value as String)
@ -638,6 +640,10 @@ class EditorFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListen
*/
private fun animateKeyboard(show: Boolean, endHandler: (() -> (Unit))? = null) {
if (show == this.isKeyboardShown) {
return
}
val height = 310.0f.px
val start = if (show) 0.0f else height
val end = if (show) height else 0.0f
@ -656,6 +662,7 @@ class EditorFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListen
this.binding.kbTopGuideline.layoutParams = lp
if (lp.guideEnd == end.toInt()) {
this.isKeyboardShown = show
endHandler?.invoke()
}

@ -966,6 +966,8 @@ class EditorViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer
val positionIndex = this.sortedActions.positions.indexOf(position)
this.handHistory.createPlayerSetup(positionIndex)
this.clearSelection()
// refresh rows
this.createRowRepresentation()
}

Loading…
Cancel
Save