|
|
|
|
@ -24,6 +24,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import kotlin.math.abs |
|
|
|
|
import kotlin.reflect.KClass |
|
|
|
|
|
|
|
|
|
enum class HHKeyboard { |
|
|
|
|
@ -56,6 +57,11 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
*/ |
|
|
|
|
private var isNew: Boolean = true |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Indicates if the settings are expanded |
|
|
|
|
*/ |
|
|
|
|
private var settingsExpanded = false |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Indicates whether the hand history is being edited or not |
|
|
|
|
*/ |
|
|
|
|
@ -146,6 +152,11 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
*/ |
|
|
|
|
private var straddlePositions: LinkedHashSet<Position> = linkedSetOf() |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Number of settings rows |
|
|
|
|
*/ |
|
|
|
|
private var settingsRowCount: Int = 1 |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Creates and configures a new HandHistory object using a [handSetup] |
|
|
|
|
*/ |
|
|
|
|
@ -265,30 +276,47 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
return rows |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun backgroundColor(position: Int, row: RowRepresentable): Int? { |
|
|
|
|
return if (position < this.settingsRowCount) R.color.gray_darker else R.color.transparent |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun arrowIcon(position: Int, row: RowRepresentable): Int? { |
|
|
|
|
return when (row) { |
|
|
|
|
HandRowType.SETTINGS_HEADER -> { |
|
|
|
|
if (this.settingsExpanded) R.drawable.ic_arrow_up else R.drawable.ic_arrow_down |
|
|
|
|
} |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun editionRowRepresentation(): MutableList<RowRepresentable> { |
|
|
|
|
|
|
|
|
|
val rows: MutableList<RowRepresentable> = mutableListOf() |
|
|
|
|
|
|
|
|
|
rows.add(HandRowType.COMMENT) |
|
|
|
|
rows.add(HandRowType.SETTINGS_HEADER) |
|
|
|
|
if (this.settingsExpanded) { |
|
|
|
|
rows.add(HandRowType.ANTE) |
|
|
|
|
|
|
|
|
|
// rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = "")) |
|
|
|
|
if (this.handSetup.type != Session.Type.CASH_GAME) { |
|
|
|
|
rows.add(HandRowType.BIG_BLIND_ANTE) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rows.add(HandRowType.PLAYER_NUMBER) |
|
|
|
|
rows.add(HandRowType.ANTE) |
|
|
|
|
// Straddle |
|
|
|
|
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.CASH_GAME) { |
|
|
|
|
rows.add(HandRowType.BIG_BLIND_ANTE) |
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.straddle, value = "")) |
|
|
|
|
positions.remove(Position.SB) |
|
|
|
|
positions.remove(Position.BB) |
|
|
|
|
rows.add(StraddleRowRepresentable(positions, this.straddlePositions)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Straddle |
|
|
|
|
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 |
|
|
|
|
// Updates the settings row count to set the proper background |
|
|
|
|
this.settingsRowCount = rows.size |
|
|
|
|
|
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.straddle, value = "")) |
|
|
|
|
positions.remove(Position.SB) |
|
|
|
|
positions.remove(Position.BB) |
|
|
|
|
rows.add(StraddleRowRepresentable(positions, this.straddlePositions)) |
|
|
|
|
} |
|
|
|
|
rows.add(HandRowType.COMMENT) |
|
|
|
|
rows.add(HandRowType.PLAYER_NUMBER) |
|
|
|
|
|
|
|
|
|
// Used to set the hero position |
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.set_hero_position, value = "")) |
|
|
|
|
@ -946,4 +974,9 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
this.createRowRepresentation() // refresh |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun toggleSettingsRows() { |
|
|
|
|
this.settingsExpanded = !this.settingsExpanded |
|
|
|
|
this.createRowRepresentation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |