|
|
|
@ -10,6 +10,7 @@ import kotlinx.android.synthetic.main.fragment_hand_history.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_settings.recyclerView |
|
|
|
import kotlinx.android.synthetic.main.fragment_settings.recyclerView |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.handhistory.ComputedAction |
|
|
|
import net.pokeranalytics.android.model.handhistory.HHBuilder |
|
|
|
import net.pokeranalytics.android.model.handhistory.HHBuilder |
|
|
|
import net.pokeranalytics.android.model.handhistory.HandSetup |
|
|
|
import net.pokeranalytics.android.model.handhistory.HandSetup |
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Action |
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Action |
|
|
|
@ -22,8 +23,10 @@ import net.pokeranalytics.android.ui.fragment.components.RealmFragment |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard |
|
|
|
import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard |
|
|
|
import net.pokeranalytics.android.ui.view.handhistory.KeyboardListener |
|
|
|
import net.pokeranalytics.android.ui.view.handhistory.KeyboardListener |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.handhistory.StreetCardHeader |
|
|
|
import net.pokeranalytics.android.ui.viewmodel.HandHistoryViewModel |
|
|
|
import net.pokeranalytics.android.ui.viewmodel.HandHistoryViewModel |
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepresentableDelegate, KeyboardListener { |
|
|
|
class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepresentableDelegate, KeyboardListener { |
|
|
|
|
|
|
|
|
|
|
|
@ -101,12 +104,20 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun edit() { |
|
|
|
private fun edit() { |
|
|
|
|
|
|
|
this.model.isEdited = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun findNextActionToEdit() { |
|
|
|
this.model.findIndexForEdition()?.let { |
|
|
|
this.model.findIndexForEdition()?.let { |
|
|
|
this.keyboard.show(it) |
|
|
|
this.keyboard.show(it) |
|
|
|
this.highlightCell(it) |
|
|
|
this.highlightCell(it) |
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
|
|
|
this.keyboard.hide() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun closeEdition() { |
|
|
|
|
|
|
|
this.model.isEdited = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun highlightCell(handHistoryKeyboard: HandHistoryKeyboard) { |
|
|
|
private fun highlightCell(handHistoryKeyboard: HandHistoryKeyboard) { |
|
|
|
@ -131,18 +142,48 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
return this.rows[position].viewType |
|
|
|
return this.rows[position].viewType |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) { |
|
|
|
|
|
|
|
super.onRowSelected(position, row, tag) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.model.isEdited) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when (row) { |
|
|
|
|
|
|
|
is ComputedAction -> { |
|
|
|
|
|
|
|
val keyboard = when (tag) { |
|
|
|
|
|
|
|
1 -> HandHistoryKeyboard.ACTION |
|
|
|
|
|
|
|
2 -> HandHistoryKeyboard.AMOUNT |
|
|
|
|
|
|
|
else -> throw PAIllegalStateException("Unmanaged tag") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.keyboard.show(keyboard) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
is StreetCardHeader -> { |
|
|
|
|
|
|
|
this.keyboard.show(HandHistoryKeyboard.CARD) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Keyboard Listener |
|
|
|
// Keyboard Listener |
|
|
|
|
|
|
|
|
|
|
|
override fun actionSelected(action: Action.Type) { |
|
|
|
override fun actionSelected(action: Action.Type) { |
|
|
|
|
|
|
|
Timber.d(">>> action $action selected") |
|
|
|
this.model.actionSelected(action) |
|
|
|
this.model.actionSelected(action) |
|
|
|
|
|
|
|
this.findNextActionToEdit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun cardSelected(value: Card, suit: Card.Suit) { |
|
|
|
override fun cardSelected(value: Card, suit: Card.Suit) { |
|
|
|
|
|
|
|
Timber.d(">>> card $value$suit selected") |
|
|
|
this.model.cardSelected(value, suit) |
|
|
|
this.model.cardSelected(value, suit) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO add test about number of cards? |
|
|
|
|
|
|
|
this.findNextActionToEdit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun amountSelected(amount: Double) { |
|
|
|
override fun amountSelected(amount: Double) { |
|
|
|
|
|
|
|
Timber.d(">>> amount $amount selected") |
|
|
|
this.model.amountSelected(amount) |
|
|
|
this.model.amountSelected(amount) |
|
|
|
|
|
|
|
this.findNextActionToEdit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |