diff --git a/app/src/main/java/net/pokeranalytics/android/calculus/ComputedStat.kt b/app/src/main/java/net/pokeranalytics/android/calculus/ComputedStat.kt index 7058e349..f54677b8 100644 --- a/app/src/main/java/net/pokeranalytics/android/calculus/ComputedStat.kt +++ b/app/src/main/java/net/pokeranalytics/android/calculus/ComputedStat.kt @@ -27,8 +27,9 @@ class ComputedStat(var stat: Stat, var value: Double, var secondValue: Double? = /** * Formats the value of the stat to be suitable for display */ - fun format(): TextFormat { - return this.stat.format(this.value, this.secondValue, this.currency) - } + val textFormat: TextFormat + get() { + return this.stat.textFormat(this.value, this.secondValue, this.currency) + } } diff --git a/app/src/main/java/net/pokeranalytics/android/calculus/Report.kt b/app/src/main/java/net/pokeranalytics/android/calculus/Report.kt index 3d241513..3d7c06cd 100644 --- a/app/src/main/java/net/pokeranalytics/android/calculus/Report.kt +++ b/app/src/main/java/net/pokeranalytics/android/calculus/Report.kt @@ -441,7 +441,7 @@ class ComputedResults(group: ComputableGroup, override fun formattedValue(stat: Stat): TextFormat { this.computedStat(stat)?.let { - return it.format() + return it.textFormat } ?: run { throw PAIllegalStateException("Missing stat in results") } @@ -460,12 +460,12 @@ class ComputedResults(group: ComputableGroup, GraphFragment.Style.BAR -> { return when (stat) { Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES, Stat.WIN_RATIO -> { - val totalStatValue = stat.format(entry.y.toDouble(), currency = null) + val totalStatValue = stat.textFormat(entry.y.toDouble(), currency = null) DefaultLegendValues(this.entryTitle(context), totalStatValue) } else -> { val entryValue = this.formattedValue(stat) - val countValue = this.computedStat(Stat.NUMBER_OF_GAMES)?.format() + val countValue = this.computedStat(Stat.NUMBER_OF_GAMES)?.textFormat DefaultLegendValues(this.entryTitle(context), entryValue, countValue) } } @@ -474,12 +474,12 @@ class ComputedResults(group: ComputableGroup, return when (stat) { Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES, Stat.WIN_RATIO -> { - val totalStatValue = stat.format(entry.y.toDouble(), currency = null) + val totalStatValue = stat.textFormat(entry.y.toDouble(), currency = null) DefaultLegendValues(this.entryTitle(context), totalStatValue) } else -> { val entryValue = this.formattedValue(stat) - val totalStatValue = stat.format(entry.y.toDouble(), currency = null) + val totalStatValue = stat.textFormat(entry.y.toDouble(), currency = null) DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue) } } diff --git a/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt b/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt index 1043c434..e1b38679 100644 --- a/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt +++ b/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt @@ -135,7 +135,7 @@ enum class Stat(override var uniqueIdentifier: Int) : IntIdentifiable, RowRepres /** * Formats the value of the stat to be suitable for display */ - fun format(value: Double, secondValue: Double? = null, currency: Currency? = null): TextFormat { + fun textFormat(value: Double, secondValue: Double? = null, currency: Currency? = null): TextFormat { if (value.isNaN()) { return TextFormat(NULL_TEXT, R.color.white) diff --git a/app/src/main/java/net/pokeranalytics/android/model/TournamentType.kt b/app/src/main/java/net/pokeranalytics/android/model/TournamentType.kt index ba098741..e9a426b0 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/TournamentType.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/TournamentType.kt @@ -12,7 +12,7 @@ enum class TournamentType : RowRepresentable { companion object { val all : List get() { - return values() as List + return values().toList() } fun getValueForLabel(label: String) : TournamentType? { diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt index 87f6ee8c..4e916f8b 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt @@ -714,7 +714,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat CustomizableRowRepresentable( RowViewType.HEADER_TITLE_AMOUNT_BIG, title = getFormattedDuration(), - computedStat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency) + valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat ) ) rows.add(SeparatorRow()) @@ -724,7 +724,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat CustomizableRowRepresentable( RowViewType.HEADER_TITLE_AMOUNT_BIG, resId = R.string.pause, - computedStat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency) + valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat ) ) rows.add(SeparatorRow()) @@ -734,14 +734,14 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat CustomizableRowRepresentable( RowViewType.HEADER_TITLE_AMOUNT_BIG, title = getFormattedDuration(), - computedStat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency) + valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat ) ) rows.add( CustomizableRowRepresentable( RowViewType.HEADER_TITLE_AMOUNT, resId = R.string.hour_rate_without_pauses, - computedStat = ComputedStat(Stat.HOURLY_RATE, this.hourlyRate, currency = currency) + valueTextFormat = ComputedStat(Stat.HOURLY_RATE, this.hourlyRate, currency = currency).textFormat ) ) @@ -1131,7 +1131,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat } value?.let { - return stat.format(it, currency = currency) + return stat.textFormat(it, currency = currency) } ?: run { return TextFormat(NULL_TEXT) } @@ -1170,7 +1170,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat if (!hasMainCurrencyCode) { this.computableResult?.ratedNet?.let { ratedNet -> - right = Stat.NET_RESULT.format(ratedNet) + right = Stat.NET_RESULT.textFormat(ratedNet) } } diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt index c447de69..32998dd8 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt @@ -122,15 +122,15 @@ open class SessionSet() : RealmObject(), Timed, Filterable { override fun formattedValue(stat: Stat) : TextFormat { return when (stat) { - Stat.NET_RESULT, Stat.AVERAGE -> stat.format(this.ratedNet, currency = null) - Stat.HOURLY_DURATION, Stat.AVERAGE_HOURLY_DURATION -> stat.format(this.hourlyDuration, currency = null) - Stat.HOURLY_RATE -> stat.format(this.hourlyRate, currency = null) - Stat.HANDS_PLAYED -> stat.format(this.estimatedHands, currency = null) - Stat.HOURLY_RATE_BB -> stat.format(this.bbHourlyRate, currency = null) + Stat.NET_RESULT, Stat.AVERAGE -> stat.textFormat(this.ratedNet, currency = null) + Stat.HOURLY_DURATION, Stat.AVERAGE_HOURLY_DURATION -> stat.textFormat(this.hourlyDuration, currency = null) + Stat.HOURLY_RATE -> stat.textFormat(this.hourlyRate, currency = null) + Stat.HANDS_PLAYED -> stat.textFormat(this.estimatedHands, currency = null) + Stat.HOURLY_RATE_BB -> stat.textFormat(this.bbHourlyRate, currency = null) Stat.NET_BB_PER_100_HANDS, Stat.STANDARD_DEVIATION_BB_PER_100_HANDS -> { val netBBPer100Hands = Stat.netBBPer100Hands(this.bbNet, this.estimatedHands) if (netBBPer100Hands != null) { - return stat.format(this.estimatedHands, currency = null) + return stat.textFormat(this.estimatedHands, currency = null) } else { return TextFormat(NULL_TEXT) } diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/Transaction.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/Transaction.kt index 03caa4b6..de2fdebc 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/Transaction.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/Transaction.kt @@ -157,7 +157,7 @@ open class Transaction : RealmObject(), Manageable, StaticRowRepresentableDataSo } override fun formattedValue(stat: Stat): TextFormat { - return stat.format(this.amount, currency = this.bankroll?.utilCurrency) + return stat.textFormat(this.amount, currency = this.bankroll?.utilCurrency) } override fun legendValues( @@ -169,7 +169,7 @@ open class Transaction : RealmObject(), Manageable, StaticRowRepresentableDataSo ): LegendContent { val entryValue = this.formattedValue(stat) - val totalStatValue = stat.format(entry.y.toDouble(), currency = null) + val totalStatValue = stat.textFormat(entry.y.toDouble(), currency = null) val leftName = context.getString(R.string.amount) return DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue, leftName = leftName) } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/activity/FilterDetailsActivity.kt b/app/src/main/java/net/pokeranalytics/android/ui/activity/FilterDetailsActivity.kt index 4995c2ca..8e5f4185 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/activity/FilterDetailsActivity.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/activity/FilterDetailsActivity.kt @@ -31,7 +31,7 @@ class FilterDetailsActivity : BaseActivity() { /** * Create a new instance for result */ - fun newInstanceForResult(fragment: Fragment, filterId: String, filterCategoryOrdinal: Int, requestCode: Int, filter: Filter? = null) { + fun newInstanceForResult(fragment: Fragment, filterId: String, filterCategoryOrdinal: Int, requestCode: Int) { val intent = Intent(fragment.requireContext(), FilterDetailsActivity::class.java) intent.putExtra(IntentKey.FILTER_ID.keyName, filterId) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/BankrollDetailsFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/BankrollDetailsFragment.kt index 783c215a..87da8069 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/BankrollDetailsFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/BankrollDetailsFragment.kt @@ -134,21 +134,21 @@ class BankrollDetailsFragment : RealmFragment(), StaticRowRepresentableDataSourc CustomizableRowRepresentable( RowViewType.TITLE_VALUE, resId = R.string.bankroll, - computedStat = totalComputedStat + valueTextFormat = totalComputedStat.textFormat ) ) rows.add( CustomizableRowRepresentable( RowViewType.TITLE_VALUE, resId = R.string.net_result, - computedStat = netComputedStat + valueTextFormat = netComputedStat.textFormat ) ) rows.add( CustomizableRowRepresentable( RowViewType.TITLE_VALUE, resId = R.string.net_banked, - computedStat = netBankedComputedStat + valueTextFormat = netBankedComputedStat.textFormat ) ) @@ -162,7 +162,7 @@ class BankrollDetailsFragment : RealmFragment(), StaticRowRepresentableDataSourc CustomizableRowRepresentable( RowViewType.TITLE_VALUE, title = typeName, - computedStat = computedStat + valueTextFormat = computedStat.textFormat ) ) } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt index 72462a88..0acf9f26 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt @@ -374,7 +374,7 @@ class CalendarFragment : RealmFragment(), CoroutineScope, StaticRowRepresentable val row = CustomizableRowRepresentable( customViewType = RowViewType.TITLE_VALUE_ARROW, title = date.getDateMonth(), - computedStat = computedStat, + valueTextFormat = computedStat.textFormat, isSelectable = true ) @@ -391,7 +391,7 @@ class CalendarFragment : RealmFragment(), CoroutineScope, StaticRowRepresentable val row = CustomizableRowRepresentable( customViewType = RowViewType.TITLE_VALUE_ARROW, title = date.getDateYear(), - computedStat = computedStat, + valueTextFormat = computedStat.textFormat, isSelectable = true ) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/report/ComposableTableReportFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/report/ComposableTableReportFragment.kt index 4da7ca01..3ad11ff0 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/report/ComposableTableReportFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/report/ComposableTableReportFragment.kt @@ -88,7 +88,7 @@ open class ComposableTableReportFragment : RealmFragment(), StaticRowRepresentab if (row is StatRow) { context?.let { _ -> row.computedStat?.let { - dc.textFormat = it.format() + dc.textFormat = it.textFormat } } } @@ -98,7 +98,7 @@ open class ComposableTableReportFragment : RealmFragment(), StaticRowRepresentab override fun statFormatForRow(row: RowRepresentable): TextFormat { if (row is StatRow) { context?.let { _ -> - row.computedStat?.let { return it.format() } + row.computedStat?.let { return it.textFormat } } } return TextFormat(NULL_TEXT) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/graph/GraphUnderlyingEntry.kt b/app/src/main/java/net/pokeranalytics/android/ui/graph/GraphUnderlyingEntry.kt index 18c37842..d4c03d17 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/graph/GraphUnderlyingEntry.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/graph/GraphUnderlyingEntry.kt @@ -22,7 +22,7 @@ interface GraphUnderlyingEntry { ): LegendContent { val leftName = stat.localizedTitle(context) - val totalStatValue = stat.format(entry.y.toDouble(), currency = null) + val totalStatValue = stat.textFormat(entry.y.toDouble(), currency = null) return if (stat.legendHideRightValue) { DefaultLegendValues(this.entryTitle(context), totalStatValue, leftName = leftName) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt index 325d0f27..c074832a 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt @@ -20,10 +20,8 @@ import kotlinx.android.synthetic.main.row_hand_player_summary.view.* import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.* import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.position_button import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.ps_hand_layout -import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.settings_container -import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.title import kotlinx.android.synthetic.main.row_hhsettings_player_setup_read.view.* -import kotlinx.android.synthetic.main.row_hhsettings_position.view.* +import kotlinx.android.synthetic.main.row_recycler.view.* import kotlinx.android.synthetic.main.row_hhsettings_straddle.view.* import net.pokeranalytics.android.R import net.pokeranalytics.android.exceptions.PAIllegalStateException @@ -59,8 +57,8 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { ANTE(R.layout.row_title_value), BIG_BLIND_ANTE(R.layout.row_title_switch), ACTION_READ(R.layout.row_hand_action_read), - HERO_POSITION(R.layout.row_hhsettings_position), - PLAYER_POSITION(R.layout.row_hhsettings_position) + HERO_POSITION(R.layout.row_recycler), + PLAYER_POSITION(R.layout.row_recycler) ; override val viewType: Int = this.ordinal @@ -353,7 +351,7 @@ class HandHistoryAdapter( LinearLayoutManager(itemView.context, RecyclerView.HORIZONTAL, false) init { - itemView.position_recycler.apply { + itemView.recycler.apply { setHasFixedSize(true) layoutManager = positionViewManager adapter = positionAdapter @@ -369,8 +367,6 @@ class HandHistoryAdapter( this.positionAdapter.notifyDataSetChanged() } - itemView.title.text = adapter.dataSource.charSequenceForRow(row, itemView.context) - if (row == HandRowType.HERO_POSITION) { val heroIndex = adapter.dataSource.intForRow(row) positionAdapter.setSelectedPosition(heroIndex) @@ -522,8 +518,6 @@ class HandHistoryAdapter( override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { super.onBind(position, row, adapter) - val setupRow = row as PlayerSetupRow - val state = setupRow.state this.delegate = adapter.delegate // Position Button @@ -531,9 +525,6 @@ class HandHistoryAdapter( val positionSelected = adapter.dataSource.isSelected(position, row, PlayerSetupRow.Tag.POSITION.ordinal) itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionSelected)) - // Settings - itemView.settings_container.visibility = if (state == PlayerSetupRow.State.POSITIONS_ONLY) View.GONE else View.VISIBLE - configureCardsLayout(itemView.ps_hand_layout) } @@ -574,19 +565,9 @@ class HandHistoryAdapter( override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { super.onBind(position, row, adapter) - val setupRow = row as PlayerSetupRow - val state = setupRow.state - // Player - configurePlayerImage(itemView.player_image, position, setupRow) - - // Title - itemView.title.text = setupRow.title(itemView.context) - val visibility = if (state == PlayerSetupRow.State.SETUP_ONLY && !setupRow.hero) View.GONE else View.VISIBLE - itemView.title.visibility = visibility - + configurePlayerImage(itemView.player_image, position, row) configureEditTexts(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter) - } } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt index 365488e4..9a94f40b 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt @@ -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 contentForRow(row: RowRepresentable, context: Context, clazz: KClass) : List { - when (clazz) { + + val list = when (clazz) { Position::class -> { - return when (row) { - HandRowType.HERO_POSITION -> this.sortedActions.positions.toList() as List - HandRowType.PLAYER_POSITION -> this.handHistory.undefinedPositions() as List + 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()) as List + (cards ?: listOf()) } Player::class -> { val position = (row as PositionalRow).positionIndex val player = this.handHistory.playerSetupForPosition(position)?.player - return player?.let { listOf(it) as List } ?: 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) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt index 4fcaff3d..b432ef49 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt @@ -42,21 +42,21 @@ class PlayerSetupRow(var hero: Boolean = false, this._state = null } - fun title(context: Context): String { - return if (this.hero) { - context.getString(R.string.set_hero_position) - } else { - this.playerSetup?.let { setup -> - setup.player?.name?.let { - it - } ?: run { - this.position.value - } - } ?: run { - context.getString(R.string.set_position_details) - } - } - } +// fun title(context: Context): String { +// return if (this.hero) { +// context.getString(R.string.set_hero_position) +// } else { +// this.playerSetup?.let { setup -> +// setup.player?.name?.let { +// it +// } ?: run { +// this.position.value +// } +// } ?: run { +// context.getString(R.string.set_position_details) +// } +// } +// } override val viewType: Int get() { diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardActionView.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardActionView.kt index 133a0b11..d5016d20 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardActionView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardActionView.kt @@ -61,7 +61,7 @@ class KeyboardActionView(context: Context) : AbstractKeyboardView(context), this.positionAdapter = PositionAdapter(it) } ?: throw PAIllegalStateException("keyboard listener not set") - this.position_recycler.apply { + this.recycler.apply { setHasFixedSize(true) layoutManager = positionViewManager adapter = positionAdapter diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt index 24e583f0..394e1871 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt @@ -228,7 +228,7 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier { itemView.findViewById(R.id.stat1Value)?.let { view -> view.text = "" - row.computedStat1?.format()?.let { + row.computedStat1?.textFormat?.let { view.setTextFormat(it, itemView.context) } } @@ -243,7 +243,7 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier { itemView.findViewById(R.id.stat2Value)?.let { view -> view.text = "" - row.computedStat2?.format()?.let { + row.computedStat2?.textFormat?.let { view.setTextFormat(it, itemView.context) } } @@ -332,12 +332,12 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier { BankrollReportManager.reportForBankroll(row.bankrollId) { report -> itemView.findViewById(R.id.stat1Value)?.let { - val formattedStat = ComputedStat(Stat.NET_RESULT, report.total).format() + val formattedStat = ComputedStat(Stat.NET_RESULT, report.total).textFormat it.setTextFormat(formattedStat, itemView.context) } itemView.findViewById(R.id.stat2Value)?.let { val riskOfRuin = report.riskOfRuin ?: 0.0 - val formattedStat = ComputedStat(Stat.RISK_OF_RUIN, riskOfRuin).format() + val formattedStat = ComputedStat(Stat.RISK_OF_RUIN, riskOfRuin).textFormat it.setTextFormat(formattedStat, itemView.context) } } @@ -468,7 +468,7 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier { itemView.findViewById(R.id.gameResult)?.let { gameResult -> val result = row.result?.net ?: 0.0 val formattedStat = - ComputedStat(Stat.NET_RESULT, result, currency = row.currency).format() + ComputedStat(Stat.NET_RESULT, result, currency = row.currency).textFormat gameResult.setTextFormat(formattedStat, itemView.context) } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt index de664068..9accf488 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt @@ -116,7 +116,7 @@ class SessionRowView : FrameLayout { session.result?.net?.let { netResult -> val stat = ComputedStat(Stat.NET_RESULT, netResult, currency = session.currency) - rowSession.gameResult.setTextFormat(stat.format(), context) + rowSession.gameResult.setTextFormat(stat.textFormat, context) } // val formattedStat = ComputedStat(Stat.NET_RESULT, result, currency = session.currency).format() diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/TransactionRowView.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/TransactionRowView.kt index eb9b6fa4..7d814174 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/TransactionRowView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/TransactionRowView.kt @@ -42,7 +42,7 @@ class TransactionRowView : FrameLayout { private fun init() { val layoutInflater = LayoutInflater.from(context) rowTransaction = layoutInflater.inflate(R.layout.row_transaction_view, this, false) as ConstraintLayout - val layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT) + val layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) addView(rowTransaction, layoutParams) } @@ -56,15 +56,17 @@ class TransactionRowView : FrameLayout { rowTransaction.transactionDateNumber.text = transaction.date.getDayNumber() // Title / Game type - var title = transaction.type?.name ?: "" + " " + transaction.comment - var subtitle = transaction.bankroll?.name + val title = transaction.type?.name ?: "" + " " + transaction.comment + val subtitle = transaction.bankroll?.name rowTransaction.transactionTitle.text = title rowTransaction.transactionSubtitle.text = subtitle // Amount - val formattedStat = ComputedStat(Stat.NET_RESULT, transaction.amount, currency = transaction.bankroll?.utilCurrency).format() - rowTransaction.transactionAmount.setTextFormat(formattedStat, context) + val computedStat = ComputedStat(Stat.NET_RESULT, + transaction.amount, + currency = transaction.bankroll?.utilCurrency) + rowTransaction.transactionAmount.setTextFormat(computedStat.textFormat, context) } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt index 90519a46..15f301ff 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt @@ -47,7 +47,7 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl val computedStat = ComputedStat(Stat.NET_RESULT, report.total, currency = report.currency) itemView.findViewById(R.id.value) - ?.setTextFormat(computedStat.format(), itemView.context) + ?.setTextFormat(computedStat.textFormat, itemView.context) } val listener = View.OnClickListener { @@ -66,11 +66,12 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl // Value itemView.findViewById(R.id.value)?.let { - if (row.computedStat != null) { - val format = row.computedStat!!.format() - it.setTextFormat(format, itemView.context) - } else if (row.value != null) { + if (row.value != null) { it.text = row.value + } else if (row.valueResId != null) { + it.text = itemView.context.getString(row.valueResId!!) + } else if (row.valueTextFormat != null) { + it.setTextFormat(row.valueTextFormat!!, itemView.context) } } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/CustomizableRowRepresentable.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/CustomizableRowRepresentable.kt index 84703a44..b00c4ee0 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/CustomizableRowRepresentable.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/CustomizableRowRepresentable.kt @@ -1,10 +1,10 @@ package net.pokeranalytics.android.ui.view.rowrepresentable import android.content.Context -import net.pokeranalytics.android.calculus.ComputedStat import net.pokeranalytics.android.ui.fragment.BankrollRowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowViewType +import net.pokeranalytics.android.util.TextFormat class BankrollTotalRow(override var bankrollId: String?, var name: String) : BankrollRowRepresentable { @@ -28,7 +28,8 @@ class CustomizableRowRepresentable( override var resId: Int? = null, var title: String? = null, var value: String? = null, - var computedStat: ComputedStat? = null, + var valueResId: Int? = null, + var valueTextFormat: TextFormat? = null, var isSelectable: Boolean? = false ) : RowRepresentable { diff --git a/app/src/main/java/net/pokeranalytics/android/util/ImageUtils.kt b/app/src/main/java/net/pokeranalytics/android/util/ImageUtils.kt index 76810371..cf02ee19 100755 --- a/app/src/main/java/net/pokeranalytics/android/util/ImageUtils.kt +++ b/app/src/main/java/net/pokeranalytics/android/util/ImageUtils.kt @@ -127,7 +127,7 @@ object ImageUtils { * @param maxHeight int: Max height */ fun resizeFile(filePath: String, bitmap: Bitmap, maxWidth: Int, maxHeight: Int) { - var bitmap = bitmap + var bm = bitmap val options = BitmapFactory.Options() options.inJustDecodeBounds = true @@ -154,8 +154,8 @@ object ImageUtils { } } - bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true) - updateFile(filePath, bitmap) + bm = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true) + updateFile(filePath, bm) } /** diff --git a/app/src/main/res/layout/row_hand_action.xml b/app/src/main/res/layout/row_hand_action.xml index 55520772..26c433d0 100644 --- a/app/src/main/res/layout/row_hand_action.xml +++ b/app/src/main/res/layout/row_hand_action.xml @@ -32,7 +32,7 @@ android:layout_weight="2" android:layout_height="wrap_content" android:layout_marginStart="8dp" - android:layout_marginEnd="16dp" + android:layout_marginEnd="8dp" android:gravity="end" android:maxLines="1" /> diff --git a/app/src/main/res/layout/row_hhsettings_player_setup.xml b/app/src/main/res/layout/row_hhsettings_player_setup.xml index 1bcfbef7..05d218a8 100644 --- a/app/src/main/res/layout/row_hhsettings_player_setup.xml +++ b/app/src/main/res/layout/row_hhsettings_player_setup.xml @@ -1,61 +1,54 @@ + android:layout_height="wrap_content" + android:orientation="horizontal"> + + + + + + + + + + - + + - - - - - - - - - - + android:layout_marginEnd="8dp" + android:layout_weight="1" + android:gravity="end" + android:hint="@string/stack" + android:inputType="none" + android:maxLines="1" /> \ No newline at end of file diff --git a/app/src/main/res/layout/row_hhsettings_player_setup_read.xml b/app/src/main/res/layout/row_hhsettings_player_setup_read.xml index 5030e107..b4694868 100644 --- a/app/src/main/res/layout/row_hhsettings_player_setup_read.xml +++ b/app/src/main/res/layout/row_hhsettings_player_setup_read.xml @@ -1,7 +1,6 @@ diff --git a/app/src/main/res/layout/row_hhsettings_position.xml b/app/src/main/res/layout/row_hhsettings_position.xml deleted file mode 100644 index 8b7eca64..00000000 --- a/app/src/main/res/layout/row_hhsettings_position.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/row_recycler.xml b/app/src/main/res/layout/row_recycler.xml new file mode 100644 index 00000000..690de617 --- /dev/null +++ b/app/src/main/res/layout/row_recycler.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_hand_keyboard_action.xml b/app/src/main/res/layout/view_hand_keyboard_action.xml index ba3b7fe1..e9cb5460 100644 --- a/app/src/main/res/layout/view_hand_keyboard_action.xml +++ b/app/src/main/res/layout/view_hand_keyboard_action.xml @@ -25,7 +25,7 @@ mississipi Hero position - Set position details + Forward Video Text + tap to set player, hand or stack