Start of UI work

hh
Laurent 6 years ago
parent 52b25af5e7
commit 814d825373
  1. 7
      app/src/main/java/net/pokeranalytics/android/calculus/ComputedStat.kt
  2. 10
      app/src/main/java/net/pokeranalytics/android/calculus/Report.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  4. 2
      app/src/main/java/net/pokeranalytics/android/model/TournamentType.kt
  5. 12
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  6. 12
      app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt
  7. 4
      app/src/main/java/net/pokeranalytics/android/model/realm/Transaction.kt
  8. 2
      app/src/main/java/net/pokeranalytics/android/ui/activity/FilterDetailsActivity.kt
  9. 8
      app/src/main/java/net/pokeranalytics/android/ui/fragment/BankrollDetailsFragment.kt
  10. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarFragment.kt
  11. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/report/ComposableTableReportFragment.kt
  12. 2
      app/src/main/java/net/pokeranalytics/android/ui/graph/GraphUnderlyingEntry.kt
  13. 29
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  14. 46
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  15. 30
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/PlayerSetupRow.kt
  16. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardActionView.kt
  17. 10
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt
  18. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt
  19. 12
      app/src/main/java/net/pokeranalytics/android/ui/view/TransactionRowView.kt
  20. 11
      app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt
  21. 5
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/CustomizableRowRepresentable.kt
  22. 6
      app/src/main/java/net/pokeranalytics/android/util/ImageUtils.kt
  23. 2
      app/src/main/res/layout/row_hand_action.xml
  24. 93
      app/src/main/res/layout/row_hhsettings_player_setup.xml
  25. 1
      app/src/main/res/layout/row_hhsettings_player_setup_read.xml
  26. 21
      app/src/main/res/layout/row_hhsettings_position.xml
  27. 15
      app/src/main/res/layout/row_recycler.xml
  28. 4
      app/src/main/res/layout/view_hand_keyboard_action.xml
  29. 3
      app/src/main/res/values/strings.xml

@ -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 * Formats the value of the stat to be suitable for display
*/ */
fun format(): TextFormat { val textFormat: TextFormat
return this.stat.format(this.value, this.secondValue, this.currency) get() {
} return this.stat.textFormat(this.value, this.secondValue, this.currency)
}
} }

@ -441,7 +441,7 @@ class ComputedResults(group: ComputableGroup,
override fun formattedValue(stat: Stat): TextFormat { override fun formattedValue(stat: Stat): TextFormat {
this.computedStat(stat)?.let { this.computedStat(stat)?.let {
return it.format() return it.textFormat
} ?: run { } ?: run {
throw PAIllegalStateException("Missing stat in results") throw PAIllegalStateException("Missing stat in results")
} }
@ -460,12 +460,12 @@ class ComputedResults(group: ComputableGroup,
GraphFragment.Style.BAR -> { GraphFragment.Style.BAR -> {
return when (stat) { return when (stat) {
Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES, Stat.WIN_RATIO -> { 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) DefaultLegendValues(this.entryTitle(context), totalStatValue)
} }
else -> { else -> {
val entryValue = this.formattedValue(stat) 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) DefaultLegendValues(this.entryTitle(context), entryValue, countValue)
} }
} }
@ -474,12 +474,12 @@ class ComputedResults(group: ComputableGroup,
return when (stat) { return when (stat) {
Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES, Stat.WIN_RATIO -> { 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) DefaultLegendValues(this.entryTitle(context), totalStatValue)
} }
else -> { else -> {
val entryValue = this.formattedValue(stat) 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) DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue)
} }
} }

@ -135,7 +135,7 @@ enum class Stat(override var uniqueIdentifier: Int) : IntIdentifiable, RowRepres
/** /**
* Formats the value of the stat to be suitable for display * 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()) { if (value.isNaN()) {
return TextFormat(NULL_TEXT, R.color.white) return TextFormat(NULL_TEXT, R.color.white)

@ -12,7 +12,7 @@ enum class TournamentType : RowRepresentable {
companion object { companion object {
val all : List<TournamentType> val all : List<TournamentType>
get() { get() {
return values() as List<TournamentType> return values().toList()
} }
fun getValueForLabel(label: String) : TournamentType? { fun getValueForLabel(label: String) : TournamentType? {

@ -714,7 +714,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG, RowViewType.HEADER_TITLE_AMOUNT_BIG,
title = getFormattedDuration(), 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()) rows.add(SeparatorRow())
@ -724,7 +724,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG, RowViewType.HEADER_TITLE_AMOUNT_BIG,
resId = R.string.pause, 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()) rows.add(SeparatorRow())
@ -734,14 +734,14 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG, RowViewType.HEADER_TITLE_AMOUNT_BIG,
title = getFormattedDuration(), 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( rows.add(
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT, RowViewType.HEADER_TITLE_AMOUNT,
resId = R.string.hour_rate_without_pauses, 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 { value?.let {
return stat.format(it, currency = currency) return stat.textFormat(it, currency = currency)
} ?: run { } ?: run {
return TextFormat(NULL_TEXT) return TextFormat(NULL_TEXT)
} }
@ -1170,7 +1170,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
if (!hasMainCurrencyCode) { if (!hasMainCurrencyCode) {
this.computableResult?.ratedNet?.let { ratedNet -> this.computableResult?.ratedNet?.let { ratedNet ->
right = Stat.NET_RESULT.format(ratedNet) right = Stat.NET_RESULT.textFormat(ratedNet)
} }
} }

@ -122,15 +122,15 @@ open class SessionSet() : RealmObject(), Timed, Filterable {
override fun formattedValue(stat: Stat) : TextFormat { override fun formattedValue(stat: Stat) : TextFormat {
return when (stat) { return when (stat) {
Stat.NET_RESULT, Stat.AVERAGE -> stat.format(this.ratedNet, currency = null) Stat.NET_RESULT, Stat.AVERAGE -> stat.textFormat(this.ratedNet, currency = null)
Stat.HOURLY_DURATION, Stat.AVERAGE_HOURLY_DURATION -> stat.format(this.hourlyDuration, currency = null) Stat.HOURLY_DURATION, Stat.AVERAGE_HOURLY_DURATION -> stat.textFormat(this.hourlyDuration, currency = null)
Stat.HOURLY_RATE -> stat.format(this.hourlyRate, currency = null) Stat.HOURLY_RATE -> stat.textFormat(this.hourlyRate, currency = null)
Stat.HANDS_PLAYED -> stat.format(this.estimatedHands, currency = null) Stat.HANDS_PLAYED -> stat.textFormat(this.estimatedHands, currency = null)
Stat.HOURLY_RATE_BB -> stat.format(this.bbHourlyRate, 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 -> { Stat.NET_BB_PER_100_HANDS, Stat.STANDARD_DEVIATION_BB_PER_100_HANDS -> {
val netBBPer100Hands = Stat.netBBPer100Hands(this.bbNet, this.estimatedHands) val netBBPer100Hands = Stat.netBBPer100Hands(this.bbNet, this.estimatedHands)
if (netBBPer100Hands != null) { if (netBBPer100Hands != null) {
return stat.format(this.estimatedHands, currency = null) return stat.textFormat(this.estimatedHands, currency = null)
} else { } else {
return TextFormat(NULL_TEXT) return TextFormat(NULL_TEXT)
} }

@ -157,7 +157,7 @@ open class Transaction : RealmObject(), Manageable, StaticRowRepresentableDataSo
} }
override fun formattedValue(stat: Stat): TextFormat { 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( override fun legendValues(
@ -169,7 +169,7 @@ open class Transaction : RealmObject(), Manageable, StaticRowRepresentableDataSo
): LegendContent { ): LegendContent {
val entryValue = this.formattedValue(stat) 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) val leftName = context.getString(R.string.amount)
return DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue, leftName = leftName) return DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue, leftName = leftName)
} }

@ -31,7 +31,7 @@ class FilterDetailsActivity : BaseActivity() {
/** /**
* Create a new instance for result * 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) val intent = Intent(fragment.requireContext(), FilterDetailsActivity::class.java)
intent.putExtra(IntentKey.FILTER_ID.keyName, filterId) intent.putExtra(IntentKey.FILTER_ID.keyName, filterId)

@ -134,21 +134,21 @@ class BankrollDetailsFragment : RealmFragment(), StaticRowRepresentableDataSourc
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.TITLE_VALUE, RowViewType.TITLE_VALUE,
resId = R.string.bankroll, resId = R.string.bankroll,
computedStat = totalComputedStat valueTextFormat = totalComputedStat.textFormat
) )
) )
rows.add( rows.add(
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.TITLE_VALUE, RowViewType.TITLE_VALUE,
resId = R.string.net_result, resId = R.string.net_result,
computedStat = netComputedStat valueTextFormat = netComputedStat.textFormat
) )
) )
rows.add( rows.add(
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.TITLE_VALUE, RowViewType.TITLE_VALUE,
resId = R.string.net_banked, resId = R.string.net_banked,
computedStat = netBankedComputedStat valueTextFormat = netBankedComputedStat.textFormat
) )
) )
@ -162,7 +162,7 @@ class BankrollDetailsFragment : RealmFragment(), StaticRowRepresentableDataSourc
CustomizableRowRepresentable( CustomizableRowRepresentable(
RowViewType.TITLE_VALUE, RowViewType.TITLE_VALUE,
title = typeName, title = typeName,
computedStat = computedStat valueTextFormat = computedStat.textFormat
) )
) )
} }

@ -374,7 +374,7 @@ class CalendarFragment : RealmFragment(), CoroutineScope, StaticRowRepresentable
val row = CustomizableRowRepresentable( val row = CustomizableRowRepresentable(
customViewType = RowViewType.TITLE_VALUE_ARROW, customViewType = RowViewType.TITLE_VALUE_ARROW,
title = date.getDateMonth(), title = date.getDateMonth(),
computedStat = computedStat, valueTextFormat = computedStat.textFormat,
isSelectable = true isSelectable = true
) )
@ -391,7 +391,7 @@ class CalendarFragment : RealmFragment(), CoroutineScope, StaticRowRepresentable
val row = CustomizableRowRepresentable( val row = CustomizableRowRepresentable(
customViewType = RowViewType.TITLE_VALUE_ARROW, customViewType = RowViewType.TITLE_VALUE_ARROW,
title = date.getDateYear(), title = date.getDateYear(),
computedStat = computedStat, valueTextFormat = computedStat.textFormat,
isSelectable = true isSelectable = true
) )

@ -88,7 +88,7 @@ open class ComposableTableReportFragment : RealmFragment(), StaticRowRepresentab
if (row is StatRow) { if (row is StatRow) {
context?.let { _ -> context?.let { _ ->
row.computedStat?.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 { override fun statFormatForRow(row: RowRepresentable): TextFormat {
if (row is StatRow) { if (row is StatRow) {
context?.let { _ -> context?.let { _ ->
row.computedStat?.let { return it.format() } row.computedStat?.let { return it.textFormat }
} }
} }
return TextFormat(NULL_TEXT) return TextFormat(NULL_TEXT)

@ -22,7 +22,7 @@ interface GraphUnderlyingEntry {
): LegendContent { ): LegendContent {
val leftName = stat.localizedTitle(context) 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) { return if (stat.legendHideRightValue) {
DefaultLegendValues(this.entryTitle(context), totalStatValue, leftName = leftName) DefaultLegendValues(this.entryTitle(context), totalStatValue, leftName = leftName)

@ -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.*
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.position_button 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.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_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 kotlinx.android.synthetic.main.row_hhsettings_straddle.view.*
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.PAIllegalStateException import net.pokeranalytics.android.exceptions.PAIllegalStateException
@ -59,8 +57,8 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable {
ANTE(R.layout.row_title_value), ANTE(R.layout.row_title_value),
BIG_BLIND_ANTE(R.layout.row_title_switch), BIG_BLIND_ANTE(R.layout.row_title_switch),
ACTION_READ(R.layout.row_hand_action_read), ACTION_READ(R.layout.row_hand_action_read),
HERO_POSITION(R.layout.row_hhsettings_position), HERO_POSITION(R.layout.row_recycler),
PLAYER_POSITION(R.layout.row_hhsettings_position) PLAYER_POSITION(R.layout.row_recycler)
; ;
override val viewType: Int = this.ordinal override val viewType: Int = this.ordinal
@ -353,7 +351,7 @@ class HandHistoryAdapter(
LinearLayoutManager(itemView.context, RecyclerView.HORIZONTAL, false) LinearLayoutManager(itemView.context, RecyclerView.HORIZONTAL, false)
init { init {
itemView.position_recycler.apply { itemView.recycler.apply {
setHasFixedSize(true) setHasFixedSize(true)
layoutManager = positionViewManager layoutManager = positionViewManager
adapter = positionAdapter adapter = positionAdapter
@ -369,8 +367,6 @@ class HandHistoryAdapter(
this.positionAdapter.notifyDataSetChanged() this.positionAdapter.notifyDataSetChanged()
} }
itemView.title.text = adapter.dataSource.charSequenceForRow(row, itemView.context)
if (row == HandRowType.HERO_POSITION) { if (row == HandRowType.HERO_POSITION) {
val heroIndex = adapter.dataSource.intForRow(row) val heroIndex = adapter.dataSource.intForRow(row)
positionAdapter.setSelectedPosition(heroIndex) positionAdapter.setSelectedPosition(heroIndex)
@ -522,8 +518,6 @@ class HandHistoryAdapter(
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)
val setupRow = row as PlayerSetupRow
val state = setupRow.state
this.delegate = adapter.delegate this.delegate = adapter.delegate
// Position Button // Position Button
@ -531,9 +525,6 @@ class HandHistoryAdapter(
val positionSelected = adapter.dataSource.isSelected(position, row, PlayerSetupRow.Tag.POSITION.ordinal) val positionSelected = adapter.dataSource.isSelected(position, row, PlayerSetupRow.Tag.POSITION.ordinal)
itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionSelected)) 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) configureCardsLayout(itemView.ps_hand_layout)
} }
@ -574,19 +565,9 @@ class HandHistoryAdapter(
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)
val setupRow = row as PlayerSetupRow
val state = setupRow.state
// Player // Player
configurePlayerImage(itemView.player_image, position, setupRow) configurePlayerImage(itemView.player_image, position, row)
// 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
configureEditTexts(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter) configureEditTexts(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter)
} }
} }

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

@ -42,21 +42,21 @@ class PlayerSetupRow(var hero: Boolean = false,
this._state = null this._state = null
} }
fun title(context: Context): String { // fun title(context: Context): String {
return if (this.hero) { // return if (this.hero) {
context.getString(R.string.set_hero_position) // context.getString(R.string.set_hero_position)
} else { // } else {
this.playerSetup?.let { setup -> // this.playerSetup?.let { setup ->
setup.player?.name?.let { // setup.player?.name?.let {
it // it
} ?: run { // } ?: run {
this.position.value // this.position.value
} // }
} ?: run { // } ?: run {
context.getString(R.string.set_position_details) // context.getString(R.string.set_position_details)
} // }
} // }
} // }
override val viewType: Int override val viewType: Int
get() { get() {

@ -61,7 +61,7 @@ class KeyboardActionView(context: Context) : AbstractKeyboardView(context),
this.positionAdapter = PositionAdapter(it) this.positionAdapter = PositionAdapter(it)
} ?: throw PAIllegalStateException("keyboard listener not set") } ?: throw PAIllegalStateException("keyboard listener not set")
this.position_recycler.apply { this.recycler.apply {
setHasFixedSize(true) setHasFixedSize(true)
layoutManager = positionViewManager layoutManager = positionViewManager
adapter = positionAdapter adapter = positionAdapter

@ -228,7 +228,7 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier {
itemView.findViewById<AppCompatTextView?>(R.id.stat1Value)?.let { view -> itemView.findViewById<AppCompatTextView?>(R.id.stat1Value)?.let { view ->
view.text = "" view.text = ""
row.computedStat1?.format()?.let { row.computedStat1?.textFormat?.let {
view.setTextFormat(it, itemView.context) view.setTextFormat(it, itemView.context)
} }
} }
@ -243,7 +243,7 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier {
itemView.findViewById<AppCompatTextView?>(R.id.stat2Value)?.let { view -> itemView.findViewById<AppCompatTextView?>(R.id.stat2Value)?.let { view ->
view.text = "" view.text = ""
row.computedStat2?.format()?.let { row.computedStat2?.textFormat?.let {
view.setTextFormat(it, itemView.context) view.setTextFormat(it, itemView.context)
} }
} }
@ -332,12 +332,12 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier {
BankrollReportManager.reportForBankroll(row.bankrollId) { report -> BankrollReportManager.reportForBankroll(row.bankrollId) { report ->
itemView.findViewById<AppCompatTextView>(R.id.stat1Value)?.let { itemView.findViewById<AppCompatTextView>(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) it.setTextFormat(formattedStat, itemView.context)
} }
itemView.findViewById<AppCompatTextView>(R.id.stat2Value)?.let { itemView.findViewById<AppCompatTextView>(R.id.stat2Value)?.let {
val riskOfRuin = report.riskOfRuin ?: 0.0 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) it.setTextFormat(formattedStat, itemView.context)
} }
} }
@ -468,7 +468,7 @@ enum class RowViewType(private var layoutRes: Int) : ViewIdentifier {
itemView.findViewById<AppCompatTextView>(R.id.gameResult)?.let { gameResult -> itemView.findViewById<AppCompatTextView>(R.id.gameResult)?.let { gameResult ->
val result = row.result?.net ?: 0.0 val result = row.result?.net ?: 0.0
val formattedStat = 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) gameResult.setTextFormat(formattedStat, itemView.context)
} }

@ -116,7 +116,7 @@ class SessionRowView : FrameLayout {
session.result?.net?.let { netResult -> session.result?.net?.let { netResult ->
val stat = ComputedStat(Stat.NET_RESULT, netResult, currency = session.currency) 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() // val formattedStat = ComputedStat(Stat.NET_RESULT, result, currency = session.currency).format()

@ -42,7 +42,7 @@ class TransactionRowView : FrameLayout {
private fun init() { private fun init() {
val layoutInflater = LayoutInflater.from(context) val layoutInflater = LayoutInflater.from(context)
rowTransaction = layoutInflater.inflate(R.layout.row_transaction_view, this, false) as ConstraintLayout 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) addView(rowTransaction, layoutParams)
} }
@ -56,15 +56,17 @@ class TransactionRowView : FrameLayout {
rowTransaction.transactionDateNumber.text = transaction.date.getDayNumber() rowTransaction.transactionDateNumber.text = transaction.date.getDayNumber()
// Title / Game type // Title / Game type
var title = transaction.type?.name ?: "" + " " + transaction.comment val title = transaction.type?.name ?: "" + " " + transaction.comment
var subtitle = transaction.bankroll?.name val subtitle = transaction.bankroll?.name
rowTransaction.transactionTitle.text = title rowTransaction.transactionTitle.text = title
rowTransaction.transactionSubtitle.text = subtitle rowTransaction.transactionSubtitle.text = subtitle
// Amount // Amount
val formattedStat = ComputedStat(Stat.NET_RESULT, transaction.amount, currency = transaction.bankroll?.utilCurrency).format() val computedStat = ComputedStat(Stat.NET_RESULT,
rowTransaction.transactionAmount.setTextFormat(formattedStat, context) transaction.amount,
currency = transaction.bankroll?.utilCurrency)
rowTransaction.transactionAmount.setTextFormat(computedStat.textFormat, context)
} }

@ -47,7 +47,7 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
val computedStat = val computedStat =
ComputedStat(Stat.NET_RESULT, report.total, currency = report.currency) ComputedStat(Stat.NET_RESULT, report.total, currency = report.currency)
itemView.findViewById<AppCompatTextView?>(R.id.value) itemView.findViewById<AppCompatTextView?>(R.id.value)
?.setTextFormat(computedStat.format(), itemView.context) ?.setTextFormat(computedStat.textFormat, itemView.context)
} }
val listener = View.OnClickListener { val listener = View.OnClickListener {
@ -66,11 +66,12 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
// Value // Value
itemView.findViewById<AppCompatTextView?>(R.id.value)?.let { itemView.findViewById<AppCompatTextView?>(R.id.value)?.let {
if (row.computedStat != null) { if (row.value != null) {
val format = row.computedStat!!.format()
it.setTextFormat(format, itemView.context)
} else if (row.value != null) {
it.text = row.value 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)
} }
} }

@ -1,10 +1,10 @@
package net.pokeranalytics.android.ui.view.rowrepresentable package net.pokeranalytics.android.ui.view.rowrepresentable
import android.content.Context import android.content.Context
import net.pokeranalytics.android.calculus.ComputedStat
import net.pokeranalytics.android.ui.fragment.BankrollRowRepresentable import net.pokeranalytics.android.ui.fragment.BankrollRowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.util.TextFormat
class BankrollTotalRow(override var bankrollId: String?, var name: String) : BankrollRowRepresentable { class BankrollTotalRow(override var bankrollId: String?, var name: String) : BankrollRowRepresentable {
@ -28,7 +28,8 @@ class CustomizableRowRepresentable(
override var resId: Int? = null, override var resId: Int? = null,
var title: String? = null, var title: String? = null,
var value: String? = null, var value: String? = null,
var computedStat: ComputedStat? = null, var valueResId: Int? = null,
var valueTextFormat: TextFormat? = null,
var isSelectable: Boolean? = false var isSelectable: Boolean? = false
) : RowRepresentable { ) : RowRepresentable {

@ -127,7 +127,7 @@ object ImageUtils {
* @param maxHeight int: Max height * @param maxHeight int: Max height
*/ */
fun resizeFile(filePath: String, bitmap: Bitmap, maxWidth: Int, maxHeight: Int) { fun resizeFile(filePath: String, bitmap: Bitmap, maxWidth: Int, maxHeight: Int) {
var bitmap = bitmap var bm = bitmap
val options = BitmapFactory.Options() val options = BitmapFactory.Options()
options.inJustDecodeBounds = true options.inJustDecodeBounds = true
@ -154,8 +154,8 @@ object ImageUtils {
} }
} }
bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true) bm = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true)
updateFile(filePath, bitmap) updateFile(filePath, bm)
} }
/** /**

@ -32,7 +32,7 @@
android:layout_weight="2" android:layout_weight="2"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="8dp"
android:gravity="end" android:gravity="end"
android:maxLines="1" /> android:maxLines="1" />

@ -1,61 +1,54 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- <androidx.appcompat.widget.AppCompatTextView-->
<!-- android:id="@+id/title"-->
<!-- style="@style/PokerAnalyticsTheme.TextView.RowTitle"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:layout_marginStart="8dp" />-->
<net.pokeranalytics.android.ui.view.PlayerImageView
android:id="@+id/player_image"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="8dp"
android:background="@android:color/transparent" />
<androidx.appcompat.widget.AppCompatTextView <com.google.android.material.button.MaterialButton
android:id="@+id/title" android:id="@+id/position_button"
style="@style/PokerAnalyticsTheme.TextView.RowTitle" style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="match_parent" android:layout_width="44dp"
android:layout_height="wrap_content" android:layout_height="44dp"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp" /> android:layout_marginStart="8dp" />
<LinearLayout <LinearLayout
android:id="@+id/settings_container" android:id="@+id/ps_hand_layout"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_weight="1.2"
android:background="@drawable/rounded_board_background"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="4dp"
android:paddingEnd="0dp" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/stack_edit_text"
style="@style/PokerAnalyticsTheme.EditText"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"> android:layout_marginEnd="8dp"
android:layout_weight="1"
<net.pokeranalytics.android.ui.view.PlayerImageView android:gravity="end"
android:id="@+id/player_image" android:hint="@string/stack"
android:layout_width="48dp" android:inputType="none"
android:layout_height="48dp" android:maxLines="1" />
android:background="@android:color/transparent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/position_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginStart="8dp"/>
<LinearLayout
android:id="@+id/ps_hand_layout"
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1.2"
android:background="@drawable/rounded_board_background"
android:layout_marginStart="8dp"
android:paddingStart="4dp"
android:paddingEnd="0dp"
android:gravity="center"/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/stack_edit_text"
style="@style/PokerAnalyticsTheme.EditText"
android:hint="@string/stack"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="end"
android:inputType="none"
android:maxLines="1"
android:layout_marginStart="8dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/settings_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
style="@style/PokerAnalyticsTheme.TextView.RowTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/position_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

@ -25,7 +25,7 @@
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/position_recycler" android:id="@+id/recycler"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="44dp" android:layout_height="44dp"
android:layout_weight="1" android:layout_weight="1"
@ -38,7 +38,7 @@
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/position_recycler" app:layout_constraintTop_toBottomOf="@id/recycler"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

@ -794,9 +794,10 @@
<string name="backspace"></string> <string name="backspace"></string>
<string name="mississipi">mississipi</string> <string name="mississipi">mississipi</string>
<string name="set_hero_position">Hero position</string> <string name="set_hero_position">Hero position</string>
<string name="set_position_details">Set position details</string> <!-- <string name="set_position_details">Set position details</string>-->
<string name="forward">Forward</string> <string name="forward">Forward</string>
<string name="video">Video</string> <string name="video">Video</string>
<string name="text">Text</string> <string name="text">Text</string>
<string name="hh_player_setting">tap to set player, hand or stack</string>
</resources> </resources>

Loading…
Cancel
Save