From 2bf6972bea4b39ecb3cc23156d8488b2eec1124b Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 23 Mar 2020 13:13:51 +0100 Subject: [PATCH] Fixes issue with stack changes --- .../ui/modules/handhistory/HandHistoryFragment.kt | 1 + .../android/ui/modules/handhistory/model/ActionList.kt | 10 ++++++++-- .../ui/modules/handhistory/model/ComputedAction.kt | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt index d1577b78..59f6e638 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt @@ -410,6 +410,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL override fun amountValidated() { Timber.d(">>> amount validated") this.model.amountValidated() + this.handHistoryAdapter.notifyDataSetChanged() // a stack update can change an allin amount this.findNextActionToEdit(userInitiated = true) } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt index e1a4fc30..26c5740a 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt @@ -642,8 +642,14 @@ class ActionList(var listener: ActionListListener) : ArrayList() this.filter { it.action.position == positionIndex }.forEach { ca -> 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 { ca.playerRemainingStack = null } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt index 1e9d9046..32a263b7 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt @@ -66,9 +66,9 @@ class ComputedAction(var manager: ActionManager, */ 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.amount = null }