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 e34bf092..80821af0 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 @@ -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 + } /*** diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt index ba5f5048..003d6787 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt @@ -113,7 +113,7 @@ class PlayerSetupRow(var hero: Boolean = false, } } - fun setStack(amount: Double) { + fun setStack(amount: Double?) { this.playerSetup?.stack = amount }