|
|
|
|
@ -272,7 +272,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
|
|
|
|
|
rows.add(HandRowType.COMMENT) |
|
|
|
|
|
|
|
|
|
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.ANTE) |
|
|
|
|
@ -292,14 +292,28 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Used to set the hero position |
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.set_hero_position, value = "")) |
|
|
|
|
rows.add(HandRowType.HERO_POSITION) |
|
|
|
|
|
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.players, value = "")) |
|
|
|
|
|
|
|
|
|
// Used to select an available position to set details for that position |
|
|
|
|
if (this.handHistory.playerSetups.size < this.handHistory.numberOfPlayers) { |
|
|
|
|
rows.add( |
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
customViewType = HandRowType.HEADER, |
|
|
|
|
resId = R.string.players, |
|
|
|
|
valueResId = R.string.hh_player_setting) |
|
|
|
|
) |
|
|
|
|
rows.add(HandRowType.PLAYER_POSITION) |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
rows.add( |
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
customViewType = HandRowType.HEADER, |
|
|
|
|
resId = R.string.players, |
|
|
|
|
value = "") |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rows.addAll(this.playerSetups()) |
|
|
|
|
|
|
|
|
|
Street.values().forEach { street -> |
|
|
|
|
@ -472,8 +486,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val row = this.rowRepresentables[this.currentSelection.index] |
|
|
|
|
when (row) { |
|
|
|
|
when (val row = this.rowRepresentables[this.currentSelection.index]) { |
|
|
|
|
is ComputedAction -> { |
|
|
|
|
amount?.let { |
|
|
|
|
this.sortedActions.setAmount(this.actionIndexForSelection, amount) |
|
|
|
|
@ -723,8 +736,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
HandRowType.PLAYER_NUMBER -> this.handHistory.numberOfPlayers.toString() |
|
|
|
|
HandRowType.COMMENT -> this.handHistory.comment ?: context.getString(R.string.comment) |
|
|
|
|
HandRowType.ANTE -> this.handHistory.ante.formatted() |
|
|
|
|
HandRowType.HERO_POSITION -> context.getString(R.string.set_hero_position) |
|
|
|
|
HandRowType.PLAYER_POSITION -> context.getString(R.string.set_position_details) |
|
|
|
|
// HandRowType.HERO_POSITION -> context.getString(R.string.set_hero_position) |
|
|
|
|
// HandRowType.PLAYER_POSITION -> context.getString(R.string.set_position_details) |
|
|
|
|
is ComputedAction -> row.action.formattedAmount |
|
|
|
|
is StreetCardsRow -> row.cardsForTag(tag)?.formatted(context) |
|
|
|
|
is PlayerSetupRow -> { |
|
|
|
|
@ -744,11 +757,12 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun <T : Any> contentForRow(row: RowRepresentable, context: Context, clazz: KClass<T>) : List<T> { |
|
|
|
|
when (clazz) { |
|
|
|
|
|
|
|
|
|
val list = when (clazz) { |
|
|
|
|
Position::class -> { |
|
|
|
|
return when (row) { |
|
|
|
|
HandRowType.HERO_POSITION -> this.sortedActions.positions.toList() as List<T> |
|
|
|
|
HandRowType.PLAYER_POSITION -> this.handHistory.undefinedPositions() as List<T> |
|
|
|
|
when (row) { |
|
|
|
|
HandRowType.HERO_POSITION -> this.sortedActions.positions.toList() |
|
|
|
|
HandRowType.PLAYER_POSITION -> this.handHistory.undefinedPositions() |
|
|
|
|
else -> throw PAIllegalStateException("undefined contentForRow:Position for $row") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -765,15 +779,16 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
} |
|
|
|
|
else -> { throw PAIllegalStateException("unmanaged contentForRow for Card") } |
|
|
|
|
} |
|
|
|
|
return (cards ?: listOf<Card>()) as List<T> |
|
|
|
|
(cards ?: listOf()) |
|
|
|
|
} |
|
|
|
|
Player::class -> { |
|
|
|
|
val position = (row as PositionalRow).positionIndex |
|
|
|
|
val player = this.handHistory.playerSetupForPosition(position)?.player |
|
|
|
|
return player?.let { listOf(it) as List<T> } ?: listOf() |
|
|
|
|
player?.let { listOf(it) } ?: listOf() |
|
|
|
|
} |
|
|
|
|
else -> { throw PAIllegalStateException("unmanaged contentForRow for $row") } |
|
|
|
|
} |
|
|
|
|
return listOf() |
|
|
|
|
return list.filterIsInstance(clazz.java) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun boolForRow(row: RowRepresentable): Boolean { |
|
|
|
|
@ -866,7 +881,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Sets both positionIndex and [position] for a PlayerSetup inside a [playerSetupRow] |
|
|
|
|
* Creates a PlayerSetup for the given [position] |
|
|
|
|
* Refreshes the RowRepresentable list |
|
|
|
|
*/ |
|
|
|
|
fun createPlayerSetupForPosition(position: Position) { |
|
|
|
|
val positionIndex = this.sortedActions.positions.indexOf(position) |
|
|
|
|
|