Fixes issue with stack changes

hh
Laurent 6 years ago
parent bbd4d3640a
commit 2bf6972bea
  1. 1
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  2. 10
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt
  3. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt

@ -410,6 +410,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun amountValidated() { override fun amountValidated() {
Timber.d(">>> amount validated") Timber.d(">>> amount validated")
this.model.amountValidated() this.model.amountValidated()
this.handHistoryAdapter.notifyDataSetChanged() // a stack update can change an allin amount
this.findNextActionToEdit(userInitiated = true) this.findNextActionToEdit(userInitiated = true)
} }

@ -642,8 +642,14 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
this.filter { it.action.position == positionIndex }.forEach { ca -> this.filter { it.action.position == positionIndex }.forEach { ca ->
remainingStack?.let { rs -> remainingStack?.let { rs ->
remainingStack = rs - ca.action.effectiveAmount
ca.playerRemainingStack = remainingStack if (ca.action.type?.isAllin == false) {
remainingStack = rs - ca.action.effectiveAmount
ca.playerRemainingStack = remainingStack
} else {
ca.setType(ca.action.type!!) // updates the action amount
}
} ?: run { } ?: run {
ca.playerRemainingStack = null ca.playerRemainingStack = null
} }

@ -66,9 +66,9 @@ class ComputedAction(var manager: ActionManager,
*/ */
fun setType(type: Action.Type) { fun setType(type: Action.Type) {
val typeChange = (this.action.type != null) val typeChange = (this.action.type != type)
if (this.action.type != type) { if (typeChange) {
this.action.type = type this.action.type = type
this.action.amount = null this.action.amount = null
} }

Loading…
Cancel
Save