Manages clear for amounts

hh
Laurent 6 years ago
parent ef52c4a071
commit 889f347969
  1. 18
      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,8 +395,13 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
* Sets the typed amount in the relevant ComputedAction
*/
fun amountValidated() {
try {
this.currentAmount?.toDouble()?.let { 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) {
@ -410,12 +415,14 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
this.handHistory.bigBlind = amount
this.sortedActions.updateBlinds()
}
2 -> this.handHistory.ante = amount
2 -> this.handHistory.ante = amount ?: 0.0
}
}
is ComputedAction -> {
amount?.let {
this.sortedActions.setAmount(this.actionIndexForSelection, amount)
}
}
is PlayerSetupRow -> {
row.setStack(amount)
}
@ -423,10 +430,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
}
this.currentAmount = null
}
} catch (e: NumberFormatException) {
Timber.w("Parsing exception: ${e.message}")
}
}
/***

@ -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