Fixes #12 + inconsistencies with ante / bba behavior

hh
Laurent 6 years ago
parent 0824ff51d6
commit 6bfbbba581
  1. 12
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt
  2. 5
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  3. 9
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt

@ -86,23 +86,11 @@ open class HandHistory : RealmObject(), Deletable, RowRepresentable, Filterable,
* The ante * The ante
*/ */
var ante: Double = 0.0 var ante: Double = 0.0
set(value) {
field = value
if (this.bigBlindAnte) {
this.bigBlindAnte = false
}
}
/*** /***
* Big blind ante * Big blind ante
*/ */
var bigBlindAnte: Boolean = false var bigBlindAnte: Boolean = false
set(value) {
field = value
if (this.ante > 0) {
this.ante = 0.0
}
}
/*** /***
* Number of players in the hand * Number of players in the hand

@ -5,6 +5,7 @@ import android.app.Activity
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.view.* import android.view.*
import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AccelerateDecelerateInterpolator
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
@ -373,7 +374,9 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
} }
HandRowType.BIG_BLIND_ANTE -> { HandRowType.BIG_BLIND_ANTE -> {
this.model.setBigBlindAnte(value as Boolean) 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 -> { HandRowType.HERO_POSITION -> {
this.model.setHeroPosition(value as Position) this.model.setHeroPosition(value as Position)

@ -948,6 +948,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
*/ */
fun setAnte(ante: Double) { fun setAnte(ante: Double) {
this.handHistory.ante = ante this.handHistory.ante = ante
this.handHistory.bigBlindAnte = false
val positionIndexes = (0 until this.handHistory.numberOfPlayers).toList() val positionIndexes = (0 until this.handHistory.numberOfPlayers).toList()
this.sortedActions.updateRemainingStacksForPositions(positionIndexes) this.sortedActions.updateRemainingStacksForPositions(positionIndexes)
@ -957,8 +958,12 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
* Sets whether the hand uses big blind ante or not * Sets whether the hand uses big blind ante or not
*/ */
fun setBigBlindAnte(bigBlindAnte: Boolean) { fun setBigBlindAnte(bigBlindAnte: Boolean) {
this.handHistory.bigBlindAnte = bigBlindAnte if (bigBlindAnte != this.handHistory.bigBlindAnte) { // we check this because table notification can trigger a listener and call this
this.sortedActions.updateBigBlindRemainingStack() this.handHistory.bigBlindAnte = bigBlindAnte
this.handHistory.ante = 0.0
this.sortedActions.updateBigBlindRemainingStack()
}
} }
/*** /***

Loading…
Cancel
Save