Manages clear for amounts

hh
Laurent 6 years ago
parent ef52c4a071
commit 889f347969
  1. 58
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  2. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt

@ -395,38 +395,42 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
* Sets the typed amount in the relevant ComputedAction * Sets the typed amount in the relevant ComputedAction
*/ */
fun amountValidated() { fun amountValidated() {
try {
this.currentAmount?.toDouble()?.let { amount -> val amount = try {
this.currentAmount?.toDouble()
val row = this.rowRepresentables[this.currentSelection.index] } catch (e: NumberFormatException) {
when (row) { Timber.w("Parsing exception: ${e.message}")
HandRowType.BLINDS -> { null
when (this.currentSelection.tag) { }
0 -> {
this.handHistory.smallBlind = amount val row = this.rowRepresentables[this.currentSelection.index]
this.sortedActions.updateBlinds() when (row) {
} HandRowType.BLINDS -> {
1 -> { when (this.currentSelection.tag) {
this.handHistory.bigBlind = amount 0 -> {
this.sortedActions.updateBlinds() this.handHistory.smallBlind = amount
} this.sortedActions.updateBlinds()
2 -> this.handHistory.ante = amount
}
}
is ComputedAction -> {
this.sortedActions.setAmount(this.actionIndexForSelection, amount)
} }
is PlayerSetupRow -> { 1 -> {
row.setStack(amount) this.handHistory.bigBlind = amount
this.sortedActions.updateBlinds()
} }
else -> {} 2 -> this.handHistory.ante = amount ?: 0.0
} }
this.currentAmount = null
} }
} catch (e: NumberFormatException) { is ComputedAction -> {
Timber.w("Parsing exception: ${e.message}") amount?.let {
this.sortedActions.setAmount(this.actionIndexForSelection, amount)
}
}
is PlayerSetupRow -> {
row.setStack(amount)
}
else -> {}
} }
this.currentAmount = null
} }
/*** /***

@ -113,7 +113,7 @@ class PlayerSetupRow(var hero: Boolean = false,
} }
} }
fun setStack(amount: Double) { fun setStack(amount: Double?) {
this.playerSetup?.stack = amount this.playerSetup?.stack = amount
} }

Loading…
Cancel
Save