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
*/
fun amountValidated() {
try {
this.currentAmount?.toDouble()?.let { amount ->
val row = this.rowRepresentables[this.currentSelection.index]
when (row) {
HandRowType.BLINDS -> {
when (this.currentSelection.tag) {
0 -> {
this.handHistory.smallBlind = amount
this.sortedActions.updateBlinds()
}
1 -> {
this.handHistory.bigBlind = amount
this.sortedActions.updateBlinds()
}
2 -> this.handHistory.ante = amount
}
}
is ComputedAction -> {
this.sortedActions.setAmount(this.actionIndexForSelection, amount)
val amount = try {
this.currentAmount?.toDouble()
} catch (e: NumberFormatException) {
Timber.w("Parsing exception: ${e.message}")
null
}
val row = this.rowRepresentables[this.currentSelection.index]
when (row) {
HandRowType.BLINDS -> {
when (this.currentSelection.tag) {
0 -> {
this.handHistory.smallBlind = amount
this.sortedActions.updateBlinds()
}
is PlayerSetupRow -> {
row.setStack(amount)
1 -> {
this.handHistory.bigBlind = amount
this.sortedActions.updateBlinds()
}
else -> {}
2 -> this.handHistory.ante = amount ?: 0.0
}
this.currentAmount = null
}
} catch (e: NumberFormatException) {
Timber.w("Parsing exception: ${e.message}")
is ComputedAction -> {
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
}

Loading…
Cancel
Save