From 6bfbbba581597eae0c5e3062cd61b03362baa348 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 8 Apr 2020 14:06:11 +0200 Subject: [PATCH] Fixes #12 + inconsistencies with ante / bba behavior --- .../android/model/realm/handhistory/HandHistory.kt | 12 ------------ .../ui/modules/handhistory/HandHistoryFragment.kt | 5 ++++- .../handhistory/model/HandHistoryViewModel.kt | 9 +++++++-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt index e655da13..24479a24 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt @@ -86,23 +86,11 @@ open class HandHistory : RealmObject(), Deletable, RowRepresentable, Filterable, * The ante */ var ante: Double = 0.0 - set(value) { - field = value - if (this.bigBlindAnte) { - this.bigBlindAnte = false - } - } /*** * Big blind ante */ var bigBlindAnte: Boolean = false - set(value) { - field = value - if (this.ante > 0) { - this.ante = 0.0 - } - } /*** * Number of players in the hand 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 0d9006b4..f9bb7ca5 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 @@ -5,6 +5,7 @@ import android.app.Activity import android.app.AlertDialog import android.content.Intent import android.os.Bundle +import android.os.Handler import android.view.* import android.view.animation.AccelerateDecelerateInterpolator import androidx.constraintlayout.widget.ConstraintLayout @@ -373,7 +374,9 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL } HandRowType.BIG_BLIND_ANTE -> { this.model.setBigBlindAnte(value as Boolean) - this.handHistoryAdapter.notifyDataSetChanged() +// val f = { this.handHistoryAdapter.notifyDataSetChanged() } + Handler().postDelayed({ this.handHistoryAdapter.notifyDataSetChanged() }, 250L) +// this.handHistoryAdapter.notifyDataSetChanged() } HandRowType.HERO_POSITION -> { this.model.setHeroPosition(value as Position) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt index f649de3b..0b0dd04f 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt @@ -948,6 +948,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra */ fun setAnte(ante: Double) { this.handHistory.ante = ante + this.handHistory.bigBlindAnte = false val positionIndexes = (0 until this.handHistory.numberOfPlayers).toList() this.sortedActions.updateRemainingStacksForPositions(positionIndexes) @@ -957,8 +958,12 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra * Sets whether the hand uses big blind ante or not */ fun setBigBlindAnte(bigBlindAnte: Boolean) { - this.handHistory.bigBlindAnte = bigBlindAnte - this.sortedActions.updateBigBlindRemainingStack() + if (bigBlindAnte != this.handHistory.bigBlindAnte) { // we check this because table notification can trigger a listener and call this + this.handHistory.bigBlindAnte = bigBlindAnte + this.handHistory.ante = 0.0 + + this.sortedActions.updateBigBlindRemainingStack() + } } /***