Split blinds row into ante + BB ante

hh
Laurent 6 years ago
parent 98743fd365
commit d6abbb3579
  1. 127
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  2. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  3. 70
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  4. 42
      app/src/main/res/layout/row_hhsettings_blinds.xml

@ -15,7 +15,6 @@ import com.google.android.material.chip.Chip
import kotlinx.android.synthetic.main.row_hand_action.view.* import kotlinx.android.synthetic.main.row_hand_action.view.*
import kotlinx.android.synthetic.main.row_hand_cards.view.* import kotlinx.android.synthetic.main.row_hand_cards.view.*
import kotlinx.android.synthetic.main.row_hand_player_summary.view.* import kotlinx.android.synthetic.main.row_hand_player_summary.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 kotlinx.android.synthetic.main.row_hhsettings_straddle.view.* import kotlinx.android.synthetic.main.row_hhsettings_straddle.view.*
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
@ -42,11 +41,12 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, H
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),
STREET(R.layout.row_hand_cards), STREET(R.layout.row_hand_cards),
BLINDS(R.layout.row_hhsettings_blinds),
STRADDLE(R.layout.row_hhsettings_straddle), STRADDLE(R.layout.row_hhsettings_straddle),
COMMENT(R.layout.row_hhsettings_comments), COMMENT(R.layout.row_hhsettings_comments),
PLAYER_NUMBER(R.layout.row_title_value), PLAYER_NUMBER(R.layout.row_title_value),
PLAYER_SETUP(R.layout.row_hhsettings_player_setup) PLAYER_SETUP(R.layout.row_hhsettings_player_setup),
ANTE(R.layout.row_title_value),
BIG_BLIND_ANTE(R.layout.row_title_switch)
; ;
override val viewType: Int = this.ordinal override val viewType: Int = this.ordinal
@ -55,59 +55,47 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, H
get() { return this.ordinal } get() { return this.ordinal }
override fun tagsForCompletion(): List<Int> { override fun tagsForCompletion(): List<Int> {
return when (this) { // return when (this) {
BLINDS -> listOf(0, 1) // BLINDS -> listOf(0, 1)
else -> listOf() // else -> listOf()
} // }
return listOf()
} }
override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean { override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean {
return when (this) {
BLINDS -> {
when (tag) {
0 -> (handHistory.smallBlind == null)
1 -> (handHistory.bigBlind == null)
else -> false
}
}
else -> false
}
}
// override fun tagForCompletion(
// handHistory: HandHistory,
// minTag: Int?
// ): Int? {
// return when (this) { // return when (this) {
// BLINDS -> { // BLINDS -> {
// when { // when (tag) {
// handHistory.smallBlind == null -> 0 // 0 -> (handHistory.smallBlind == null)
// handHistory.bigBlind == null -> 1 // 1 -> (handHistory.bigBlind == null)
// else -> null // else -> false
// }
// } // }
// else -> null
// } // }
// else -> false
// } // }
return false
}
override fun keyboardForTag(tag: Int): HHKeyboard? { override fun keyboardForTag(tag: Int): HHKeyboard? {
return when (this) { // return when (this) {
BLINDS -> HHKeyboard.AMOUNT // BLINDS -> HHKeyboard.AMOUNT
else -> throw PAIllegalStateException("unmanaged tag $tag") // else -> throw PAIllegalStateException("unmanaged tag $tag")
} // }
throw PAIllegalStateException("unmanaged tag $tag")
} }
override fun amountForTag(handHistory: HandHistory, tag: Int): Double? { override fun amountForTag(handHistory: HandHistory, tag: Int): Double? {
return when (this) { // return when (this) {
BLINDS -> { // BLINDS -> {
when (tag) { // when (tag) {
0 -> handHistory.smallBlind // 0 -> handHistory.smallBlind
1 -> handHistory.bigBlind // 1 -> handHistory.bigBlind
else -> null // else -> null
} // }
} // }
else -> null // else -> null
} // }
return null
} }
override val bottomSheetType: BottomSheetType override val bottomSheetType: BottomSheetType
@ -115,6 +103,7 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, H
return when(this) { return when(this) {
PLAYER_NUMBER -> BottomSheetType.GRID PLAYER_NUMBER -> BottomSheetType.GRID
COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES
ANTE -> BottomSheetType.NUMERIC_TEXT
else -> BottomSheetType.NONE else -> BottomSheetType.NONE
} }
} }
@ -124,6 +113,8 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, H
return when(this) { return when(this) {
PLAYER_NUMBER -> R.string.number_of_players PLAYER_NUMBER -> R.string.number_of_players
COMMENT -> R.string.comment COMMENT -> R.string.comment
ANTE -> R.string.ante
BIG_BLIND_ANTE -> R.string.bb_ante_option
else -> null else -> null
} }
} }
@ -160,11 +151,12 @@ class HandHistoryAdapter(
HandRowType.ACTION -> RowHandAction(layout) HandRowType.ACTION -> RowHandAction(layout)
HandRowType.STREET -> RowHandStreet(layout) HandRowType.STREET -> RowHandStreet(layout)
HandRowType.PLAYER_SUMMARY -> RowHandPlayerSummary(layout) HandRowType.PLAYER_SUMMARY -> RowHandPlayerSummary(layout)
HandRowType.BLINDS -> RowHandBlinds(layout) // HandRowType.BLINDS -> RowHandBlinds(layout)
HandRowType.STRADDLE -> RowHandStraddle(layout) HandRowType.STRADDLE -> RowHandStraddle(layout)
HandRowType.PLAYER_SETUP -> RowHandPlayerSetup(layout) HandRowType.PLAYER_SETUP -> RowHandPlayerSetup(layout)
HandRowType.COMMENT -> RowViewHolder(layout) HandRowType.COMMENT -> RowViewHolder(layout)
HandRowType.PLAYER_NUMBER -> RowViewHolder(layout) HandRowType.PLAYER_NUMBER, HandRowType.ANTE,
HandRowType.BIG_BLIND_ANTE -> RowViewHolder(layout)
} }
} }
@ -304,28 +296,28 @@ class HandHistoryAdapter(
} }
inner class RowHandBlinds(itemView: View) : RowHandHolder(itemView) { // inner class RowHandBlinds(itemView: View) : RowHandHolder(itemView) {
//
init { // init {
itemView.smallBlindEditText.tag = 0 //// itemView.smallBlindEditText.tag = 0
itemView.bigBlindEditText.tag = 1 //// itemView.bigBlindEditText.tag = 1
itemView.anteEditText.tag = 2 // itemView.anteEditText.tag = 0
//
setClickListener(itemView.smallBlindEditText) //// setClickListener(itemView.smallBlindEditText)
setClickListener(itemView.bigBlindEditText) //// setClickListener(itemView.bigBlindEditText)
setClickListener(itemView.anteEditText) // setClickListener(itemView.anteEditText)
//
} // }
//
// sb, bb, ante, bb ante // // sb, bb, ante, bb ante
//
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)
//
configureEditTexts(0..2, position, row, adapter) // configureEditTexts(0, position, row, adapter)
} // }
//
} // }
inner class RowHandStraddle(itemView: View) : RowHandHolder(itemView) { inner class RowHandStraddle(itemView: View) : RowHandHolder(itemView) {
@ -586,7 +578,6 @@ class HandHistoryAdapter(
// Settings // Settings
itemView.settings_container.visibility = if (state == PlayerSetupRow.State.POSITIONS_ONLY) View.GONE else View.VISIBLE itemView.settings_container.visibility = if (state == PlayerSetupRow.State.POSITIONS_ONLY) View.GONE else View.VISIBLE
configureCardsLayout(itemView.psHandLayout) configureCardsLayout(itemView.psHandLayout)
// configureEditTexts(PlayerSetupRow.Tag.HAND.ordinal, position, row, adapter) // configureEditTexts(PlayerSetupRow.Tag.HAND.ordinal, position, row, adapter)
configureEditTexts(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter) configureEditTexts(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter)

@ -307,6 +307,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
this.model.setNumberOfPlayers(value as Int) this.model.setNumberOfPlayers(value as Int)
this.handHistoryAdapter.notifyDataSetChanged() this.handHistoryAdapter.notifyDataSetChanged()
} }
HandRowType.ANTE -> {
this.model.setAnte(value as Double? ?: 0.0)
this.handHistoryAdapter.notifyItemChanged(this.indexOfRowRepresentable(row))
}
is ComputedAction -> { is ComputedAction -> {
this.model.currentAmount = value as String this.model.currentAmount = value as String
} }

@ -1,6 +1,7 @@
package net.pokeranalytics.android.ui.modules.handhistory.model package net.pokeranalytics.android.ui.modules.handhistory.model
import android.content.Context import android.content.Context
import android.text.InputType
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import io.realm.Realm import io.realm.Realm
@ -15,6 +16,7 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource
import net.pokeranalytics.android.ui.modules.handhistory.HandRowType import net.pokeranalytics.android.ui.modules.handhistory.HandRowType
import net.pokeranalytics.android.ui.modules.handhistory.views.CardCentralizer import net.pokeranalytics.android.ui.modules.handhistory.views.CardCentralizer
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable
import net.pokeranalytics.android.util.extensions.formatted import net.pokeranalytics.android.util.extensions.formatted
import timber.log.Timber import timber.log.Timber
@ -215,7 +217,11 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = "")) rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = ""))
rows.add(HandRowType.PLAYER_NUMBER) rows.add(HandRowType.PLAYER_NUMBER)
rows.add(HandRowType.BLINDS) rows.add(HandRowType.ANTE)
if (this.handSetup.type != Session.Type.CASH_GAME) {
rows.add(HandRowType.BIG_BLIND_ANTE)
}
val positions = Position.positionsPerPlayers(this.handHistory.numberOfPlayers) val positions = Position.positionsPerPlayers(this.handHistory.numberOfPlayers)
if (this.handSetup.type != Session.Type.TOURNAMENT && this.isNew && positions.size > 2) { // don't allow any straddle changes if not new, or if it's a headsup if (this.handSetup.type != Session.Type.TOURNAMENT && this.isNew && positions.size > 2) { // don't allow any straddle changes if not new, or if it's a headsup
@ -406,19 +412,19 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
val row = this.rowRepresentables[this.currentSelection.index] val row = this.rowRepresentables[this.currentSelection.index]
when (row) { when (row) {
HandRowType.BLINDS -> { // HandRowType.BLINDS -> {
when (this.currentSelection.tag) { // when (this.currentSelection.tag) {
0 -> { // 0 -> {
this.handHistory.smallBlind = amount // this.handHistory.smallBlind = amount
this.sortedActions.updateBlinds() // this.sortedActions.updateBlinds()
} // }
1 -> { // 1 -> {
this.handHistory.bigBlind = amount // this.handHistory.bigBlind = amount
this.sortedActions.updateBlinds() // this.sortedActions.updateBlinds()
} // }
2 -> this.handHistory.ante = amount ?: 0.0 // 2 -> this.handHistory.ante = amount ?: 0.0
} // }
} // }
is ComputedAction -> { is ComputedAction -> {
amount?.let { amount?.let {
this.sortedActions.setAmount(this.actionIndexForSelection, amount) this.sortedActions.setAmount(this.actionIndexForSelection, amount)
@ -623,7 +629,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
override fun isFocusable(position: Int, row: RowRepresentable, tag: Int): Boolean { override fun isFocusable(position: Int, row: RowRepresentable, tag: Int): Boolean {
return when (row) { return when (row) {
HandRowType.BLINDS -> this.isSelected(position, row, tag) // HandRowType.BLINDS -> this.isSelected(position, row, tag)
is ComputedAction -> { is ComputedAction -> {
val isSelected = this.isSelected(position, row, tag) val isSelected = this.isSelected(position, row, tag)
when (tag) { when (tag) {
@ -650,14 +656,15 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
val string = when (row) { val string = when (row) {
HandRowType.PLAYER_NUMBER -> this.handHistory.numberOfPlayers.toString() HandRowType.PLAYER_NUMBER -> this.handHistory.numberOfPlayers.toString()
HandRowType.COMMENT -> this.handHistory.comment ?: context.getString(R.string.comment) HandRowType.COMMENT -> this.handHistory.comment ?: context.getString(R.string.comment)
HandRowType.BLINDS -> { HandRowType.ANTE -> this.handHistory.ante.formatted()
when (tag) { // HandRowType.BLINDS -> {
0 -> this.handHistory.smallBlind?.formatted() // when (tag) {
1 -> this.handHistory.bigBlind?.formatted() // 0 -> this.handHistory.smallBlind?.formatted()
2 -> this.handHistory.ante.formatted() // 1 -> this.handHistory.bigBlind?.formatted()
else -> throw PAIllegalStateException("Unmanaged case with $row, tag = $tag") // 2 -> this.handHistory.ante.formatted()
} // else -> throw PAIllegalStateException("Unmanaged case with $row, tag = $tag")
} // }
// }
is ComputedAction -> row.action.formattedAmount is ComputedAction -> row.action.formattedAmount
is StreetCardsRow -> row.cardsForTag(tag)?.formatted(context) is StreetCardsRow -> row.cardsForTag(tag)?.formatted(context)
is PlayerSetupRow -> { is PlayerSetupRow -> {
@ -701,6 +708,19 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
return listOf() return listOf()
} }
override fun boolForRow(row: RowRepresentable): Boolean {
return when (row) {
HandRowType.BIG_BLIND_ANTE -> this.handHistory.bigBlindAnte
else -> throw PAIllegalStateException("undefined boolForRow for $row")
}
}
override fun editDescriptors(row: RowRepresentable): ArrayList<RowRepresentableEditDescriptor>? {
return when (row) {
HandRowType.ANTE -> arrayListOf(RowRepresentableEditDescriptor(defaultValue = this.handHistory.ante, inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_FLAG_DECIMAL))
else -> null
}
}
/*** /***
* Defines the positions having straddled and * Defines the positions having straddled and
@ -800,4 +820,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
return this.sortedActions.positions.elementAt(positionIndex) return this.sortedActions.positions.elementAt(positionIndex)
} }
fun setAnte(ante: Double) {
this.handSetup.ante = ante
}
} }

@ -4,27 +4,27 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText <!-- <androidx.appcompat.widget.AppCompatEditText-->
android:id="@+id/smallBlindEditText" <!-- android:id="@+id/smallBlindEditText"-->
style="@style/PokerAnalyticsTheme.EditText" <!-- style="@style/PokerAnalyticsTheme.EditText"-->
android:layout_width="0dp" <!-- android:layout_width="0dp"-->
android:hint="@string/smallblind" <!-- android:hint="@string/smallblind"-->
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:inputType="none"-->
android:maxLines="1" /> <!-- android:maxLines="1" />-->
<androidx.appcompat.widget.AppCompatEditText <!-- <androidx.appcompat.widget.AppCompatEditText-->
android:id="@+id/bigBlindEditText" <!-- android:id="@+id/bigBlindEditText"-->
style="@style/PokerAnalyticsTheme.EditText" <!-- style="@style/PokerAnalyticsTheme.EditText"-->
android:layout_width="0dp" <!-- android:layout_width="0dp"-->
android:hint="@string/bigblind" <!-- android:hint="@string/bigblind"-->
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:inputType="none"-->
android:maxLines="1" /> <!-- android:maxLines="1" />-->
<androidx.appcompat.widget.AppCompatEditText <androidx.appcompat.widget.AppCompatEditText
android:id="@+id/anteEditText" android:id="@+id/anteEditText"
@ -41,7 +41,7 @@
android:id="@+id/bbAnteSwitch" android:id="@+id/bbAnteSwitch"
android:layout_width="0dp" android:layout_width="0dp"
android:textColorHint="@color/white" android:textColorHint="@color/white"
android:hint="@string/ante" android:hint="@string/bb_ante_option"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"

Loading…
Cancel
Save