Fixes #7 : Validate player stack if adding a new position row

hh
Laurent 6 years ago
parent 34b622d689
commit 6bde91f26b
  1. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  2. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt

@ -354,6 +354,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { override fun onRowValueChanged(value: Any?, row: RowRepresentable) {
if (this.model.selectionLiveData.value != null) {
this.model.amountValidated() // validates any edited amount before possibly clearing action
}
when (row) { when (row) {
HandRowType.COMMENT -> { HandRowType.COMMENT -> {
this.model.handHistory.comment = value as? String this.model.handHistory.comment = value as? String

@ -503,11 +503,15 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
*/ */
fun amountValidated() { fun amountValidated() {
if (this.currentAmount?.isEmpty() == true) {
return
}
val amount = try { val amount = try {
this.currentAmount?.toDouble() this.currentAmount?.toDouble()
} catch (e: NumberFormatException) { } catch (e: NumberFormatException) {
Timber.w("Parsing exception: ${e.message}") Timber.w("Parsing exception: ${e.message}")
null return
} }
when (val row = this.rowRepresentables[this.currentSelection.index]) { when (val row = this.rowRepresentables[this.currentSelection.index]) {

Loading…
Cancel
Save