Manages SB + BB

hh
Laurent 6 years ago
parent 534809e3e9
commit d10bd13379
  1. 175
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  2. 89
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  3. 14
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt
  4. 26
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt
  5. 53
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  6. 15
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/CardsRow.kt
  7. 1
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardAmountView.kt
  8. 3
      app/src/main/res/layout/row_hhsettings_blinds.xml

@ -11,11 +11,13 @@ import android.widget.EditText
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
import kotlinx.android.synthetic.main.row_hand_action.view.*
import kotlinx.android.synthetic.main.row_hhsettings_blinds.view.* import kotlinx.android.synthetic.main.row_hhsettings_blinds.view.*
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.* import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.*
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.Street import net.pokeranalytics.android.model.handhistory.Street
import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.model.realm.handhistory.formatted import net.pokeranalytics.android.model.realm.handhistory.formatted
import net.pokeranalytics.android.ui.adapter.BindableHolder import net.pokeranalytics.android.ui.adapter.BindableHolder
import net.pokeranalytics.android.ui.adapter.RecyclerAdapter import net.pokeranalytics.android.ui.adapter.RecyclerAdapter
@ -24,6 +26,7 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.extensions.px import net.pokeranalytics.android.ui.extensions.px
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction
import net.pokeranalytics.android.ui.modules.handhistory.model.HHKeyboard import net.pokeranalytics.android.ui.modules.handhistory.model.HHKeyboard
import net.pokeranalytics.android.ui.modules.handhistory.model.HandHistoryRow
import net.pokeranalytics.android.ui.modules.handhistory.model.StraddleRowRepresentable import net.pokeranalytics.android.ui.modules.handhistory.model.StraddleRowRepresentable
import net.pokeranalytics.android.ui.modules.handhistory.views.PlayerCardsRow import net.pokeranalytics.android.ui.modules.handhistory.views.PlayerCardsRow
import net.pokeranalytics.android.ui.modules.handhistory.views.StreetCardsRow import net.pokeranalytics.android.ui.modules.handhistory.views.StreetCardsRow
@ -33,7 +36,7 @@ import net.pokeranalytics.android.ui.view.rowrepresentable.ViewIdentifier
import timber.log.Timber import timber.log.Timber
enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, HandHistoryRow {
HEADER(R.layout.row_header_value), HEADER(R.layout.row_header_value),
ACTION(R.layout.row_hand_action), ACTION(R.layout.row_hand_action),
PLAYER_SUMMARY(R.layout.row_hand_player_summary), PLAYER_SUMMARY(R.layout.row_hand_player_summary),
@ -48,6 +51,40 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable {
override val identifier: Int override val identifier: Int
get() { return this.ordinal } get() { return this.ordinal }
override fun tagForCompletion(handHistory: HandHistory): Int? {
return when (this) {
BLINDS -> {
when {
handHistory.smallBlind == null -> 0
handHistory.bigBlind == null -> 1
else -> null
}
}
else -> null
}
}
override fun keyboardForTag(tag: Int): HHKeyboard {
return when (this) {
BLINDS -> HHKeyboard.AMOUNT
else -> throw PAIllegalStateException("unmanaged tag $tag")
}
}
override fun amountForTag(handHistory: HandHistory, tag: Int): Double? {
return when (this) {
BLINDS -> {
when (tag) {
0 -> handHistory.smallBlind
1 -> handHistory.bigBlind
else -> null
}
}
else -> null
}
}
} }
class HandHistoryAdapter( class HandHistoryAdapter(
@ -95,6 +132,41 @@ class HandHistoryAdapter(
} }
} }
inner class RowHandStraddle(itemView: View) : RowHandHolder(itemView) {
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
super.onBind(position, row, adapter)
val straddleRow = row as StraddleRowRepresentable
itemView.positionsChipGroup.removeAllViews()
straddleRow.positions.forEach { pos ->
val chip = Chip(itemView.context)
chip.id = View.generateViewId()
// chip.tag = filter.id
chip.text = pos.shortValue
chip.chipStartPadding = 8f.px
chip.chipEndPadding = 8f.px
chip.isChecked = straddleRow.selectedPositions.contains(pos)
chip.setOnClickListener {
if (chip.isChecked) {
val added = straddleRow.add(pos)
chip.isChecked = added
} else {
straddleRow.remove(pos)
}
adapter.delegate?.onRowValueChanged(straddleRow.selectedPositions, row)
}
itemView.positionsChipGroup.addView(chip)
}
}
}
abstract inner class RowHandHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { abstract inner class RowHandHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder {
var currentPosition = 0 var currentPosition = 0
@ -119,6 +191,52 @@ class HandHistoryAdapter(
this.currentPosition = position this.currentPosition = position
} }
protected fun toggleFocus(editText: EditText, focused: Boolean) {
if (focused) {
editText.requestFocus()
} else {
editText.clearFocus()
}
}
open fun editTextForTag(tag: Int) : EditText {
throw PAIllegalStateException("Should overriden by class : $this")
}
}
inner class RowHandBlinds(itemView: View) : RowHandHolder(itemView) {
// sb, bb, ante, bb ante
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
super.onBind(position, row, adapter)
itemView.smallBlindEditText.setText(adapter.dataSource.stringForRow(row, 0))
itemView.bigBlindEditText.setText(adapter.dataSource.stringForRow(row, 1))
itemView.anteEditText.setText(adapter.dataSource.stringForRow(row, 2))
itemView.bbAnteSwitch.isChecked = adapter.dataSource.isSelected(position, row, 0)
val sbSelected = adapter.dataSource.isSelected(position, row, 0)
toggleFocus(itemView.smallBlindEditText, sbSelected)
val bbSelected = adapter.dataSource.isSelected(position, row, 1)
toggleFocus(itemView.bigBlindEditText, bbSelected)
val anteSelected = adapter.dataSource.isSelected(position, row, 2)
toggleFocus(itemView.anteEditText, anteSelected)
}
override fun editTextForTag(tag: Int): EditText {
return when (tag) {
0 -> itemView.smallBlindEditText
1 -> itemView.bigBlindEditText
2 -> itemView.anteEditText
else -> throw PAIllegalStateException("unmanaged tag $tag")
}
}
} }
/** /**
@ -161,6 +279,10 @@ class HandHistoryAdapter(
} }
} }
override fun editTextForTag(tag: Int): EditText {
return itemView.amountEditText
}
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
super.onBind(position, row, adapter) super.onBind(position, row, adapter)
@ -365,57 +487,6 @@ class HandHistoryAdapter(
} }
} }
inner class RowHandBlinds(itemView: View) : RowHandHolder(itemView) {
// sb, bb, ante, bb ante
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
super.onBind(position, row, adapter)
itemView.smallBlindEditText.setText(adapter.dataSource.stringForRow(row, 0))
itemView.bigBlindEditText.setText(adapter.dataSource.stringForRow(row, 1))
itemView.anteEditText.setText(adapter.dataSource.stringForRow(row, 2))
itemView.bbAnteSwitch.isChecked = adapter.dataSource.isSelected(position, row, 0)
}
}
inner class RowHandStraddle(itemView: View) : RowHandHolder(itemView) {
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
super.onBind(position, row, adapter)
val straddleRow = row as StraddleRowRepresentable
itemView.positionsChipGroup.removeAllViews()
straddleRow.positions.forEach { pos ->
val chip = Chip(itemView.context)
chip.id = View.generateViewId()
// chip.tag = filter.id
chip.text = pos.shortValue
chip.chipStartPadding = 8f.px
chip.chipEndPadding = 8f.px
chip.isChecked = straddleRow.selectedPositions.contains(pos)
chip.setOnClickListener {
if (chip.isChecked) {
val added = straddleRow.add(pos)
chip.isChecked = added
} else {
straddleRow.remove(pos)
}
adapter.delegate?.onRowValueChanged(straddleRow.selectedPositions, row)
}
itemView.positionsChipGroup.addView(chip)
}
}
}
inner class RowHandPlayerSetup(itemView: View) : RowHandHolder(itemView) { inner class RowHandPlayerSetup(itemView: View) : RowHandHolder(itemView) {
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.EditText
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import kotlinx.android.synthetic.main.fragment_hand_history.* import kotlinx.android.synthetic.main.fragment_hand_history.*
@ -20,18 +19,21 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.fragment.components.RealmFragment import net.pokeranalytics.android.ui.fragment.components.RealmFragment
import net.pokeranalytics.android.ui.modules.handhistory.model.* import net.pokeranalytics.android.ui.modules.handhistory.model.*
import net.pokeranalytics.android.ui.modules.handhistory.views.KeyboardListener import net.pokeranalytics.android.ui.modules.handhistory.views.KeyboardListener
import net.pokeranalytics.android.ui.modules.handhistory.views.PlayerCardsRow
import net.pokeranalytics.android.ui.modules.handhistory.views.StreetCardsRow
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager
import net.pokeranalytics.android.util.extensions.findById import net.pokeranalytics.android.util.extensions.findById
import net.pokeranalytics.android.util.extensions.noGroupingFormatted
import timber.log.Timber import timber.log.Timber
class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListener { class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListener {
/***
* The fragment's ViewModel
*/
private lateinit var model: HandHistoryViewModel private lateinit var model: HandHistoryViewModel
/***
* The custom adapter
*/
private lateinit var handHistoryAdapter: HandHistoryAdapter private lateinit var handHistoryAdapter: HandHistoryAdapter
companion object { companion object {
@ -99,18 +101,37 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
this.model.selectionLiveData.observeForever { selection -> this.model.selectionLiveData.observeForever { selection ->
selection?.let { selection?.let {
Timber.d("Current selection is ${selection.index} / ${selection.keyboard}") Timber.d("Current selection is ${selection.index} / ${selection.tag}")
when (it.keyboard) { val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow
when (row.keyboardForTag(it.tag)) {
HHKeyboard.ACTION -> { HHKeyboard.ACTION -> {
val positions = this.model.positionsToAct() val positions = this.model.positionsToAct()
this.keyboard.setPositions(positions) this.keyboard.setPositions(positions)
} }
HHKeyboard.AMOUNT -> { HHKeyboard.AMOUNT -> {
retrieveEditTextInputConnection(selection.index) retrieveEditTextInputConnection(selection)
} }
else -> {} else -> {}
} }
// when (row) {
// is ComputedAction -> {
// when (it.tag) {
// 0 -> {
// val positions = this.model.positionsToAct()
// this.keyboard.setPositions(positions)
// }
// 1 -> {
// retrieveEditTextInputConnection(selection.index)
// }
// else -> {}
// }
// }
// else -> {}
// }
} ?: run { } ?: run {
this.keyboard.hide() this.keyboard.hide()
} }
@ -124,11 +145,15 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
// At first, the selection is defined before the holder is bound, // At first, the selection is defined before the holder is bound,
// so we retrieve the editText inputConnection once the recycler view has been rendered // so we retrieve the editText inputConnection once the recycler view has been rendered
this.recyclerView.viewTreeObserver.addOnGlobalLayoutListener { this.recyclerView.viewTreeObserver.addOnGlobalLayoutListener {
this.model.selectionLiveData.value?.let { selection ->
if (selection.keyboard == HHKeyboard.AMOUNT) { when (this.model.currentKeyboard) {
retrieveEditTextInputConnection(selection.index) HHKeyboard.AMOUNT -> {
val selection = this.model.currentSelection
retrieveEditTextInputConnection(selection)
} }
else -> {}
} }
} }
this.keyboard.keyboardListener = this this.keyboard.keyboardListener = this
@ -136,14 +161,14 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
} }
private fun retrieveEditTextInputConnection(position: Int) { private fun retrieveEditTextInputConnection(selection: HHSelection) {
val computedAction = this.model.rowRepresentableForPosition(position) as? ComputedAction val handRow = this.model.rowRepresentableForPosition(selection.index) as? HandRowType
val holder = recyclerView.findViewHolderForAdapterPosition(position) val holder = recyclerView.findViewHolderForAdapterPosition(selection.index) as? HandHistoryAdapter.RowHandHolder
holder?.let { holder?.let {
val amountEditText = it.itemView.findViewById<EditText>(R.id.amountEditText) val amountEditText = it.editTextForTag(selection.tag)
this.keyboard.setAmountEditText(amountEditText, computedAction?.action?.amount) this.keyboard.setAmountEditText(amountEditText, handRow?.amountForTag(this.model.handHistory, selection.tag))
} ?: run { } ?: run {
Timber.d("no holder, or not RowHandAction") Timber.d("no holder, or not RowHandAction")
} }
@ -162,13 +187,18 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
private fun findNextActionToEdit(index: Int? = null) { private fun findNextActionToEdit(index: Int? = null) {
val startIndex = index ?: this.model.currentSelection.index val startIndex = index ?: this.model.currentSelection.index
this.model.findSelectionForEdition(startIndex)?.let { selection -> this.model.findSelectionForEdition(startIndex)?.let { selection ->
this.recyclerView.smoothScrollToPosition(selection.index) this.recyclerView.smoothScrollToPosition(selection.index)
if (selection.keyboard == HHKeyboard.ACTION) { this.model.currentKeyboard?.let { keyboard ->
when (keyboard) {
HHKeyboard.ACTION -> {
val availableActions = this.model.availableActions() val availableActions = this.model.availableActions()
this.keyboard.setAvailableAction(availableActions) this.keyboard.setAvailableAction(availableActions)
} else -> {}
}
this.keyboard.show(keyboard)
} }
this.keyboard.show(selection.keyboard)
} ?: run { } ?: run {
this.keyboard.hide() this.keyboard.hide()
@ -195,30 +225,9 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
// scrolls to selected position // scrolls to selected position
this.recyclerView.smoothScrollToPosition(position) this.recyclerView.smoothScrollToPosition(position)
val keyboard: HHKeyboard = when (row) { this.model.selectionLiveData.value = HHSelection(position, tag)
is ComputedAction -> {
when (tag) {
HHKeyboard.ACTION.ordinal -> HHKeyboard.ACTION
HHKeyboard.AMOUNT.ordinal -> {
Timber.d("amount = ${row.action.amount}, toString = ${row.action.amount?.noGroupingFormatted}")
this.model.currentAmount = row.action.amount?.noGroupingFormatted
HHKeyboard.AMOUNT
}
else -> throw PAIllegalStateException("Unmanaged tag value: $tag")
}
}
is StreetCardsRow, is PlayerCardsRow -> {
HHKeyboard.CARD
}
else -> throw PAIllegalStateException("unmanaged row type: $row")
}
this.model.selectionLiveData.value =
HHSelection(
position,
keyboard
)
val keyboard = (row as HandHistoryRow).keyboardForTag(tag)
if (keyboard == HHKeyboard.ACTION) { if (keyboard == HHKeyboard.ACTION) {
val availableActions = this.model.availableActions() val availableActions = this.model.availableActions()
this.keyboard.setAvailableAction(availableActions) this.keyboard.setAvailableAction(availableActions)

@ -519,4 +519,18 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
return streetActions.drop(index + 1).map { it.position } return streetActions.drop(index + 1).map { it.position }
} }
/***
* Updates the small blind amount
*/
fun updateSmallBlind(amount: Double) {
this.firstOrNull { it.action.type == Action.Type.POST_SB }?.setAmount(amount)
}
/***
* Updates the big blind amount
*/
fun updateBigBlind(amount: Double) {
this.firstOrNull { it.action.type == Action.Type.POST_BB }?.setAmount(amount)
}
} }

@ -4,6 +4,7 @@ import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.handhistory.Position import net.pokeranalytics.android.model.handhistory.Position
import net.pokeranalytics.android.model.handhistory.Street import net.pokeranalytics.android.model.handhistory.Street
import net.pokeranalytics.android.model.realm.handhistory.Action import net.pokeranalytics.android.model.realm.handhistory.Action
import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.ui.modules.handhistory.HandRowType import net.pokeranalytics.android.ui.modules.handhistory.HandRowType
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import timber.log.Timber import timber.log.Timber
@ -14,7 +15,12 @@ interface HandHistoryRow : RowRepresentable {
/*** /***
* Returns the appropriate keyboard to complete the row content * Returns the appropriate keyboard to complete the row content
*/ */
fun keyboardForCompletion() : HHKeyboard? fun tagForCompletion(handHistory: HandHistory): Int?
fun keyboardForTag(tag: Int): HHKeyboard
fun amountForTag(handHistory: HandHistory, tag: Int): Double? { return null }
} }
/*** /***
@ -160,17 +166,29 @@ class ComputedAction(var manager: ActionManager,
* All ComputedAction should have a type, so we return the action keyboard if the type is null * All ComputedAction should have a type, so we return the action keyboard if the type is null
* If the action has a type, we return the amount keyboard if the action requires one * If the action has a type, we return the amount keyboard if the action requires one
*/ */
override fun keyboardForCompletion() : HHKeyboard? { override fun tagForCompletion(handHistory: HandHistory): Int? {
Timber.d("index = ${action.index} / type = ${this.action.type} / amount = ${this.action.amount}") Timber.d("index = ${action.index} / type = ${this.action.type} / amount = ${this.action.amount}")
return if (this.action.type != null) { return if (this.action.type != null) {
if (this.requiresAmount) { if (this.requiresAmount) {
HHKeyboard.AMOUNT 1
} else { } else {
null null
} }
} else { } else {
HHKeyboard.ACTION 0
}
} }
override fun keyboardForTag(tag: Int): HHKeyboard {
return when (tag) {
0 -> HHKeyboard.ACTION
1 -> HHKeyboard.AMOUNT
else -> throw PAIllegalStateException("unmanaged tag: $tag")
}
}
override fun amountForTag(handHistory: HandHistory, tag: Int): Double? {
return this.action.amount
} }
/*** /***

@ -27,14 +27,15 @@ enum class HHKeyboard {
CARD; CARD;
} }
class HHSelection(var index: Int, var keyboard: HHKeyboard) class HHSelection(var index: Int, var tag: Int)
class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer, ActionListListener { class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer, ActionListListener {
/*** /***
* The hand history * The hand history
*/ */
private lateinit var handHistory: HandHistory lateinit var handHistory: HandHistory
private set
/*** /***
* *
@ -57,6 +58,15 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
val currentSelection: HHSelection val currentSelection: HHSelection
get() { return selectionLiveData.value ?: throw PAIllegalStateException("No selection") } get() { return selectionLiveData.value ?: throw PAIllegalStateException("No selection") }
val currentKeyboard: HHKeyboard?
get() {
this.selectionLiveData.value?.let {
val row = this.rowRepresentables[it.index] as HandHistoryRow
return row.keyboardForTag(it.tag)
}
return null
}
/*** /***
* The current amount edited by the user * The current amount edited by the user
*/ */
@ -281,12 +291,9 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
this.rowRepresentables.forEachIndexed { index, rowRepresentable -> this.rowRepresentables.forEachIndexed { index, rowRepresentable ->
if (index >= startIndex && rowRepresentable is HandHistoryRow) { if (index >= startIndex && rowRepresentable is HandHistoryRow) {
val foundKeyboard = rowRepresentable.keyboardForCompletion() val tag = rowRepresentable.tagForCompletion(this.handHistory)
if (foundKeyboard != null) { if (tag != null) {
return HHSelection( return HHSelection(index, tag)
index,
foundKeyboard
)
} }
} }
} }
@ -317,7 +324,29 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
fun amountValidated() { fun amountValidated() {
try { try {
this.currentAmount?.toDouble()?.let { amount -> this.currentAmount?.toDouble()?.let { amount ->
this.sortedActions.setAmount(this.actionIndexForSelection, amount)
val row = this.rowRepresentables[this.currentSelection.index]
when (row) {
HandRowType.BLINDS -> {
when (this.currentSelection.tag) {
0 -> {
this.handHistory.smallBlind = amount
this.sortedActions.updateSmallBlind(amount)
}
1 -> {
this.handHistory.bigBlind = amount
this.sortedActions.updateBigBlind(amount)
}
2 -> this.handHistory.ante = amount
}
}
is ComputedAction -> {
row.setAmount(amount)
}
else -> {}
}
// this.sortedActions.setAmount(this.actionIndexForSelection, amount)
this.currentAmount = null this.currentAmount = null
} }
} catch (e: NumberFormatException) { } catch (e: NumberFormatException) {
@ -475,13 +504,13 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
return when (row) { return when (row) {
HandRowType.BLINDS -> { HandRowType.BLINDS -> {
this.handHistory.bigBlindAnte false
} }
is ComputedAction -> { is ComputedAction -> {
val currentSelection = this.selectionLiveData val currentSelection = this.selectionLiveData
val isSelectedIndex = (position == currentSelection.value?.index) val isSelectedIndex = (position == currentSelection.value?.index)
val isSelectedAction = (tag == currentSelection.value?.keyboard?.ordinal) val isSelectedTag = (tag == currentSelection.value?.tag)
isSelectedIndex && isSelectedAction isSelectedIndex && isSelectedTag
} }
else -> false else -> false
} }

@ -5,6 +5,7 @@ import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.handhistory.Position import net.pokeranalytics.android.model.handhistory.Position
import net.pokeranalytics.android.model.handhistory.Street import net.pokeranalytics.android.model.handhistory.Street
import net.pokeranalytics.android.model.realm.handhistory.Card import net.pokeranalytics.android.model.realm.handhistory.Card
import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.model.realm.handhistory.PlayerSetup import net.pokeranalytics.android.model.realm.handhistory.PlayerSetup
import net.pokeranalytics.android.ui.modules.handhistory.HandRowType import net.pokeranalytics.android.ui.modules.handhistory.HandRowType
import net.pokeranalytics.android.ui.modules.handhistory.model.HHKeyboard import net.pokeranalytics.android.ui.modules.handhistory.model.HHKeyboard
@ -25,14 +26,18 @@ abstract class CardsRow(var cardHolder: CardHolder?) : HandHistoryRow {
abstract fun cardLimit() : Int? abstract fun cardLimit() : Int?
override fun keyboardForCompletion(): HHKeyboard? { override fun tagForCompletion(handHistory: HandHistory): Int? {
return when { return when {
this.cardCount < cardLimit() ?: MAX_CARDS -> HHKeyboard.CARD this.cardCount < cardLimit() ?: MAX_CARDS -> 0
this.cardHolder?.cards?.lastOrNull()?.suit == null -> HHKeyboard.CARD this.cardHolder?.cards?.lastOrNull()?.suit == null -> 0
else -> null else -> null
} }
} }
override fun keyboardForTag(tag: Int): HHKeyboard {
return HHKeyboard.CARD
}
fun cardAtIndex(index: Int): Card? { fun cardAtIndex(index: Int): Card? {
if (this.cardCount > index) { if (this.cardCount > index) {
return this.cardHolder!!.cards[index] return this.cardHolder!!.cards[index]
@ -135,6 +140,10 @@ class StreetCardsRow(var street: Street, cardHolder: CardHolder) : CardsRow(card
throw PAIllegalStateException("This cannot happen") throw PAIllegalStateException("This cannot happen")
} }
override fun tagForCompletion(handHistory: HandHistory): Int? {
return this.street.ordinal
}
override fun cardLimit() : Int { override fun cardLimit() : Int {
return this.street.totalBoardCards return this.street.totalBoardCards
} }

@ -123,7 +123,6 @@ class KeyboardAmountView(context: Context) : AbstractKeyboardView(context),
this.inputConnection = it this.inputConnection = it
} ?: run { throw PAIllegalStateException("EditText did not return an input Connection") } } ?: run { throw PAIllegalStateException("EditText did not return an input Connection") }
} }
override fun adapterRows(): List<RowRepresentable>? { override fun adapterRows(): List<RowRepresentable>? {

@ -12,6 +12,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:inputType="none"
android:maxLines="1" /> android:maxLines="1" />
<androidx.appcompat.widget.AppCompatEditText <androidx.appcompat.widget.AppCompatEditText
@ -22,6 +23,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:inputType="none"
android:maxLines="1" /> android:maxLines="1" />
<androidx.appcompat.widget.AppCompatEditText <androidx.appcompat.widget.AppCompatEditText
@ -32,6 +34,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:inputType="none"
android:maxLines="1" /> android:maxLines="1" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

Loading…
Cancel
Save