|
|
|
@ -105,15 +105,14 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
handHistoryId?.let { |
|
|
|
handHistoryId?.let { |
|
|
|
val handHistory = getRealm().findById<HandHistory>(it) |
|
|
|
val handHistory = getRealm().findById<HandHistory>(it) |
|
|
|
?: throw PAIllegalStateException("HandHistory not found") |
|
|
|
?: throw PAIllegalStateException("HandHistory not found") |
|
|
|
this.model.setHandHistory(handHistory) |
|
|
|
val hhCopy = getRealm().copyFromRealm(handHistory) |
|
|
|
|
|
|
|
this.model.setHandHistory(hhCopy) |
|
|
|
this.setEditing(false) |
|
|
|
this.setEditing(false) |
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
val configurationId= this.arguments?.getString(BundleKey.CONFIGURATION_ID.value) |
|
|
|
val configurationId= this.arguments?.getString(BundleKey.CONFIGURATION_ID.value) |
|
|
|
val attached= this.arguments?.getBoolean(BundleKey.ATTACHED.value) ?: false |
|
|
|
val attached= this.arguments?.getBoolean(BundleKey.ATTACHED.value) ?: false |
|
|
|
|
|
|
|
|
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.createNewHandHistory(getRealm(), configurationId, attached) |
|
|
|
this.model.createNewHandHistory(it, configurationId, attached) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.setEditing(true) |
|
|
|
this.setEditing(true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -438,9 +437,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
|
|
override fun amountValidated() { |
|
|
|
override fun amountValidated() { |
|
|
|
Timber.d(">>> amount validated") |
|
|
|
Timber.d(">>> amount validated") |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.amountValidated() |
|
|
|
this.model.amountValidated() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.findNextActionToEdit(userInitiated = true) |
|
|
|
this.findNextActionToEdit(userInitiated = true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -449,31 +446,23 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun amountCleared() { |
|
|
|
override fun amountCleared() { |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.clearAmount() |
|
|
|
this.model.clearAmount() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun cardValueSelected(value: Card.Value) { |
|
|
|
override fun cardValueSelected(value: Card.Value) { |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.cardValueSelected(value) |
|
|
|
this.model.cardValueSelected(value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
this.findNextActionToEdit() |
|
|
|
this.findNextActionToEdit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun cardSuitSelected(suit: Card.Suit) { |
|
|
|
override fun cardSuitSelected(suit: Card.Suit) { |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.cardSuitSelected(suit) |
|
|
|
this.model.cardSuitSelected(suit) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
this.findNextActionToEdit() |
|
|
|
this.findNextActionToEdit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun clearCards() { |
|
|
|
override fun clearCards() { |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.clearCards() |
|
|
|
this.model.clearCards() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -483,9 +472,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun cardBackSpaceSelected() { |
|
|
|
override fun cardBackSpaceSelected() { |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.deleteLastCardProperty() |
|
|
|
this.model.deleteLastCardProperty() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -619,11 +606,16 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
* Finishes the activity to go back |
|
|
|
* Finishes the activity to go back |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun deleteHand() { |
|
|
|
private fun deleteHand() { |
|
|
|
if (this.model.handHistory.isManaged) { |
|
|
|
// if (this.model.handHistory.isManaged) { |
|
|
|
|
|
|
|
// this.model.handHistory.deleteFromRealm() |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getRealm().findById<HandHistory>(this.model.handHistory.id)?.let { hh -> |
|
|
|
getRealm().executeTransaction { |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.handHistory.deleteFromRealm() |
|
|
|
hh.deleteFromRealm() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.activity?.finish() |
|
|
|
this.activity?.finish() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -631,9 +623,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
* Creates a new hand using the current hand setup |
|
|
|
* Creates a new hand using the current hand setup |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun addNewHand() { |
|
|
|
private fun addNewHand() { |
|
|
|
getRealm().executeTransaction { |
|
|
|
this.model.createNewHandHistoryWithCurrentSetup() |
|
|
|
this.model.createNewHandHistoryWithCurrentSetup(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.findNextActionToEdit(0) |
|
|
|
this.findNextActionToEdit(0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|