diff --git a/app/src/main/java/net/pokeranalytics/android/model/handhistory/ComputedAction.kt b/app/src/main/java/net/pokeranalytics/android/model/handhistory/ComputedAction.kt index 71da04a9..2145886d 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/handhistory/ComputedAction.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/handhistory/ComputedAction.kt @@ -3,10 +3,13 @@ package net.pokeranalytics.android.model.handhistory import net.pokeranalytics.android.model.realm.handhistory.Action import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowViewType -import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard interface HandHistoryRow : RowRepresentable { - fun keyboardForCompletion() : HandHistoryKeyboard? + + /*** + * Returns the appropriate keyboard to complete the row content + */ + fun keyboardForCompletion() : HHKeyboard? } class ComputedAction(var action: Action, @@ -20,8 +23,9 @@ class ComputedAction(var action: Action, val requireAmount: Boolean get() { return when(this.action.type) { - Action.Type.BET, Action.Type.RAISE -> true - Action.Type.BET_ALLIN, Action.Type.RAISE_ALLIN -> (this.playerRemainingStack == null) + Action.Type.POST_SB, Action.Type.POST_BB, + Action.Type.BET, Action.Type.RAISE -> (this.action.amount == null) + Action.Type.BET_ALLIN, Action.Type.RAISE_ALLIN -> (this.playerRemainingStack == null && this.action.amount == null) else -> false } } @@ -39,16 +43,23 @@ class ComputedAction(var action: Action, override val viewType: Int = RowViewType.ROW_HAND_ACTION.ordinal - override fun keyboardForCompletion() : HandHistoryKeyboard? { - this.action.type?.let { type -> - if (this.requireAmount && this.action.amount == null) { - return HandHistoryKeyboard.ACTION - } else { - return null - } - } ?: run { - return HandHistoryKeyboard.ACTION + override fun keyboardForCompletion() : HHKeyboard? { + return if (this.action.type != null) { + if (this.requireAmount) { + HHKeyboard.AMOUNT + } else { + null + } + } else { + HHKeyboard.ACTION } } + /*** + * Returns whether the action type can be edited + * SB / BB cannot have their action type edited + */ + val actionTypeCanBeEdited: Boolean + get() { return action.index > 1 } + } \ No newline at end of file diff --git a/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt b/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt index 61e410e7..28e65c4d 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt @@ -6,12 +6,20 @@ import net.pokeranalytics.android.model.realm.handhistory.Action import net.pokeranalytics.android.model.realm.handhistory.HandHistory import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowViewType -import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard import net.pokeranalytics.android.ui.view.handhistory.StreetCardHeader import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable +import timber.log.Timber import java.util.* import kotlin.math.min +enum class HHKeyboard { + ACTION, + AMOUNT, + CARD +} + +class HHSelection(var index: Int, var keyboard: HHKeyboard) + class HHBuilder { /*** @@ -141,6 +149,8 @@ class HHBuilder { */ fun selectAction(index: Int, actionType: Action.Type) : Boolean { + Timber.d("Sets $actionType at index: $index") + val computedAction = this.actionForIndex(index) computedAction.action.type = actionType @@ -180,6 +190,8 @@ class HHBuilder { * In the case of an UNDEFINED_ALLIN, define if it's a RAISE_ALLIN or a CALL_ALLIN */ fun setAmount(index: Int, amount: Double) { + + Timber.d("Sets $amount at index: $index") val computedAction = this.actionForIndex(index) val revisedAmount = computedAction.playerRemainingStack?.let { min(it, amount) } ?: amount @@ -302,19 +314,25 @@ class HHBuilder { return rows } + fun indexOfComputedAction(rowRepresentableIndex: Int) : Int { + val computedAction = this.currentRowRepresentables[rowRepresentableIndex] as ComputedAction + return computedAction.action.index + } + /*** * Finds the index of the first incomplete action, if existing */ - fun findIndexForEdition(): Pair? { + fun findIndexForEdition(startIndex: Int): HHSelection? { this.currentRowRepresentables.forEachIndexed { index, rowRepresentable -> - if (rowRepresentable is HandHistoryRow) { + if (index >= startIndex && rowRepresentable is HandHistoryRow) { rowRepresentable.keyboardForCompletion()?.let { keyboard -> - return Pair(index, keyboard) + return HHSelection(index, keyboard) } } } return null } -} \ No newline at end of file +} + diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt index bcfcf0c1..57363494 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt @@ -3,27 +3,29 @@ package net.pokeranalytics.android.model.realm.handhistory import io.realm.RealmObject import net.pokeranalytics.android.exceptions.PAIllegalStateException +interface CardProperty open class Card : RealmObject() { - companion object { - - fun valueFormatted(value: Int) : String { - return when(value) { - 0 -> "x" - in 2..9 -> "$value" - 10 -> "T" - 11 -> "J" - 12 -> "Q" - 13 -> "K" - 14 -> "A" - else -> throw PAIllegalStateException("card value '$value' not handled") + class Value(var value: Int) : CardProperty { + + val formatted: String + get() { + return when(value) { + 0 -> "x" + in 2..9 -> "$value" + 10 -> "T" + 11 -> "J" + 12 -> "Q" + 13 -> "K" + 14 -> "A" + else -> throw PAIllegalStateException("card value '$value' not handled") + } } - } } - enum class Suit(val value: String) { + enum class Suit(val value: String) : CardProperty { UNDEFINED("x"), SPADES("♠︎"), HEART("♥︎"), diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt index 11b582a9..eb3cb0b9 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt @@ -39,12 +39,12 @@ open class HandHistory : RealmObject(), RowRepresentable, Identifiable, Filterab /*** * The small blind */ - var smallBlind: Double = 0.0 + var smallBlind: Double? = null /*** * The big blind */ - var bigBlind: Double = 0.0 + var bigBlind: Double? = null /*** * The ante diff --git a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt index 48ab3e53..81393701 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableAdapter.kt @@ -10,6 +10,7 @@ import net.pokeranalytics.android.ui.view.RowViewType interface RowRepresentableDelegate { fun onRowSelected(position: Int, row: RowRepresentable, tag: Int = 0) {} + fun onRowDeselected(position: Int, row: RowRepresentable) {} fun onRowValueChanged(value: Any?, row: RowRepresentable) {} fun onRowDeleted(row: RowRepresentable) {} fun onRowLongClick(itemView: View, row: RowRepresentable, position: Int) {} diff --git a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt index 51021a62..120d2a2a 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt @@ -153,6 +153,13 @@ interface DisplayableDataSource { return true } + /** + * Returns whether the row, or its component, shoudl be enabled + */ + fun color(position: Int, row: RowRepresentable, tag: Int): Int? { + return null + } + /** * Returns whether the row, or its component, shoudl be enabled */ diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/HandHistoryFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/HandHistoryFragment.kt index 50ea06bc..9c34dc2e 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/HandHistoryFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/HandHistoryFragment.kt @@ -10,9 +10,7 @@ import kotlinx.android.synthetic.main.fragment_hand_history.* import kotlinx.android.synthetic.main.fragment_settings.recyclerView import net.pokeranalytics.android.R import net.pokeranalytics.android.exceptions.PAIllegalStateException -import net.pokeranalytics.android.model.handhistory.ComputedAction -import net.pokeranalytics.android.model.handhistory.HHBuilder -import net.pokeranalytics.android.model.handhistory.HandSetup +import net.pokeranalytics.android.model.handhistory.* import net.pokeranalytics.android.model.realm.handhistory.Action import net.pokeranalytics.android.model.realm.handhistory.Card import net.pokeranalytics.android.model.realm.handhistory.HandHistory @@ -21,7 +19,6 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate import net.pokeranalytics.android.ui.fragment.components.RealmFragment import net.pokeranalytics.android.ui.view.RowRepresentable -import net.pokeranalytics.android.ui.view.handhistory.HandHistoryKeyboard import net.pokeranalytics.android.ui.view.handhistory.KeyboardListener import net.pokeranalytics.android.ui.view.handhistory.StreetCardHeader import net.pokeranalytics.android.ui.viewmodel.HandHistoryViewModel @@ -105,12 +102,13 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr private fun edit() { this.model.isEdited = true + findNextActionToEdit(0) } - private fun findNextActionToEdit() { - this.model.findIndexForEdition()?.let { + private fun findNextActionToEdit(startIndex: Int) { + this.model.findIndexForEdition(startIndex)?.let { this.keyboard.show(it) - this.highlightCell(it) + this.highlightCell() } ?: run { this.keyboard.hide() } @@ -120,8 +118,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr this.model.isEdited = false } - private fun highlightCell(handHistoryKeyboard: HandHistoryKeyboard) { - + private fun highlightCell() { + this.handHistoryAdapter.notifyDataSetChanged() } // RowRepresentableDataSource @@ -149,19 +147,37 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr return } + this.model.currentSelection = HHSelection(position, HHKeyboard.values()[tag]) + when (row) { is ComputedAction -> { val keyboard = when (tag) { - 1 -> HandHistoryKeyboard.ACTION - 2 -> HandHistoryKeyboard.AMOUNT - else -> throw PAIllegalStateException("Unmanaged tag") + HHKeyboard.ACTION.ordinal -> HHKeyboard.ACTION + HHKeyboard.AMOUNT.ordinal -> HHKeyboard.AMOUNT + else -> throw PAIllegalStateException("Unmanaged tag value: $tag") } this.keyboard.show(keyboard) } is StreetCardHeader -> { - this.keyboard.show(HandHistoryKeyboard.CARD) + this.keyboard.show(HHKeyboard.CARD) } } + + } + + override fun onRowDeselected(position: Int, row: RowRepresentable) { + this.model.currentSelection = null + } + + override fun onRowValueChanged(value: Any?, row: RowRepresentable) { + this.model.currentAmount = value as String + } + + override fun color(position: Int, row: RowRepresentable, tag: Int): Int? { + val isSelectedIndex = (position == this.model.currentSelection?.index) + val isSelectedAction = (tag == this.model.currentSelection?.keyboard?.ordinal) + val color = if (isSelectedIndex && isSelectedAction) R.color.green_light else R.color.kaki_medium + return context?.getColor(color) } // Keyboard Listener @@ -169,21 +185,31 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr override fun actionSelected(action: Action.Type) { Timber.d(">>> action $action selected") this.model.actionSelected(action) - this.findNextActionToEdit() +// this.handHistoryAdapter.notifyDataSetChanged() + this.findNextActionToEdit(this.model.actionIndexForSelection) + } + + override fun cardValueSelected(value: Int) { + this.model.cardValueSelected(value) + this.handHistoryAdapter.notifyDataSetChanged() + + // TODO add test about number of cards before selecting next action? +// this.findNextActionToEdit() } - override fun cardSelected(value: Card, suit: Card.Suit) { - Timber.d(">>> card $value$suit selected") - this.model.cardSelected(value, suit) + override fun cardSuitSelected(suit: Card.Suit) { + this.model.cardSuitSelected(suit) + this.handHistoryAdapter.notifyDataSetChanged() // TODO add test about number of cards? - this.findNextActionToEdit() +// this.findNextActionToEdit() } - override fun amountSelected(amount: Double) { - Timber.d(">>> amount $amount selected") - this.model.amountSelected(amount) - this.findNextActionToEdit() + override fun amountValidated() { + Timber.d(">>> amount validated") + this.model.amountValidated() +// this.handHistoryAdapter.notifyDataSetChanged() + this.findNextActionToEdit(this.model.actionIndexForSelection) } } \ No newline at end of file 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 8558d058..4970441a 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 @@ -13,6 +13,7 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.core.widget.ContentLoadingProgressBar +import androidx.core.widget.addTextChangedListener import androidx.recyclerview.widget.RecyclerView import com.github.mikephil.charting.charts.BarChart import com.github.mikephil.charting.charts.LineChart @@ -28,6 +29,7 @@ import net.pokeranalytics.android.calculus.bankroll.BankrollReportManager import net.pokeranalytics.android.model.TableSize import net.pokeranalytics.android.model.extensions.getFormattedGameType import net.pokeranalytics.android.model.handhistory.ComputedAction +import net.pokeranalytics.android.model.handhistory.HHKeyboard import net.pokeranalytics.android.model.realm.CustomField import net.pokeranalytics.android.model.realm.Player import net.pokeranalytics.android.model.realm.Session @@ -41,6 +43,7 @@ import net.pokeranalytics.android.ui.fragment.BankrollRowRepresentable import net.pokeranalytics.android.ui.graph.AxisFormatting import net.pokeranalytics.android.ui.graph.setStyle import net.pokeranalytics.android.ui.view.rowrepresentable.* +import net.pokeranalytics.android.util.extensions.formatted import net.pokeranalytics.android.util.extensions.longDate import timber.log.Timber @@ -87,7 +90,7 @@ enum class RowViewType(private var layoutRes: Int) { // Custom row ROW_SESSION(R.layout.row_feed_session), ROW_TRANSACTION(R.layout.row_transaction), -// ROW_HAND_HISTORY(R.layout.row_hand_history), + // ROW_HAND_HISTORY(R.layout.row_hand_history), ROW_TOP_10(R.layout.row_top_10), ROW_BUTTON(R.layout.row_button), ROW_FOLLOW_US(R.layout.row_follow_us), @@ -182,8 +185,10 @@ enum class RowViewType(private var layoutRes: Int) { itemView.findViewById(R.id.title)?.let { it.text = row.localizedTitle(itemView.context) } - val computedStat = ComputedStat(Stat.NET_RESULT, report.total, currency = report.currency) - itemView.findViewById(R.id.value)?.setTextFormat(computedStat.format(), itemView.context) + val computedStat = + ComputedStat(Stat.NET_RESULT, report.total, currency = report.currency) + itemView.findViewById(R.id.value) + ?.setTextFormat(computedStat.format(), itemView.context) } val listener = View.OnClickListener { @@ -216,7 +221,8 @@ enum class RowViewType(private var layoutRes: Int) { val listener = View.OnClickListener { adapter.delegate?.onRowSelected(position, row) } - itemView.findViewById(R.id.container)?.setOnClickListener(listener) + itemView.findViewById(R.id.container) + ?.setOnClickListener(listener) } } @@ -255,7 +261,12 @@ enum class RowViewType(private var layoutRes: Int) { imageView.setImageResource(imageRes) } row.imageTint?.let { color -> - imageView.setColorFilter(ContextCompat.getColor(imageView.context, color)) + imageView.setColorFilter( + ContextCompat.getColor( + imageView.context, + color + ) + ) } if (row.imageClickable == true) { imageView.addCircleRipple() @@ -303,7 +314,8 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a follow us row */ - inner class RowFollowUsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class RowFollowUsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { itemView.findViewById(R.id.icon1)?.setOnClickListener { adapter.delegate?.onRowSelected(0, row) @@ -328,7 +340,8 @@ enum class RowViewType(private var layoutRes: Int) { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { // Title - itemView.findViewById(R.id.title)?.text = row.localizedTitle(itemView.context) + itemView.findViewById(R.id.title)?.text = + row.localizedTitle(itemView.context) // Value itemView.findViewById(R.id.value)?.let { view -> @@ -338,7 +351,8 @@ enum class RowViewType(private var layoutRes: Int) { } if (row is StatRow) { - itemView.findViewById(R.id.nextArrow)?.isVisible = row.stat.hasProgressGraph + itemView.findViewById(R.id.nextArrow)?.isVisible = + row.stat.hasProgressGraph } // Listener @@ -400,7 +414,8 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a graph */ - inner class GraphViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class GraphViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { private fun loadWithDataSet(dataSet: DataSet<*>) { val context = itemView.context @@ -460,7 +475,8 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a legend */ - inner class LegendDefaultViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class LegendDefaultViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { @@ -489,7 +505,8 @@ enum class RowViewType(private var layoutRes: Int) { val listener = View.OnClickListener { adapter.delegate?.onRowSelected(position, row) } - itemView.findViewById(R.id.container)?.setOnClickListener(listener) + itemView.findViewById(R.id.container) + ?.setOnClickListener(listener) } } @@ -525,7 +542,8 @@ enum class RowViewType(private var layoutRes: Int) { chipGroup.addView(chip) } - chipGroup.setOnCheckedChangeListener(object : ChipGroupExtension.SingleSelectionOnCheckedListener() { + chipGroup.setOnCheckedChangeListener(object : + ChipGroupExtension.SingleSelectionOnCheckedListener() { override fun onCheckedChanged(group: ChipGroup, checkedId: Int) { super.onCheckedChanged(group, checkedId) @@ -534,7 +552,10 @@ enum class RowViewType(private var layoutRes: Int) { return } - adapter.delegate?.onRowValueChanged(CustomField.Type.values()[checkedId], row) + adapter.delegate?.onRowValueChanged( + CustomField.Type.values()[checkedId], + row + ) } }) } @@ -545,11 +566,15 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a button in a row */ - inner class RowButtonViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class RowButtonViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { - itemView.findViewById(R.id.title).text = row.localizedTitle(itemView.context) - itemView.findViewById(R.id.title).isVisible = !adapter.dataSource.boolForRow(row) - itemView.findViewById(R.id.progressBar).isVisible = adapter.dataSource.boolForRow(row) + itemView.findViewById(R.id.title).text = + row.localizedTitle(itemView.context) + itemView.findViewById(R.id.title).isVisible = + !adapter.dataSource.boolForRow(row) + itemView.findViewById(R.id.progressBar).isVisible = + adapter.dataSource.boolForRow(row) val listener = View.OnClickListener { adapter.delegate?.onRowSelected(position, row) } @@ -560,7 +585,8 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a session view */ - inner class RowSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class RowSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { itemView.sessionRow.setData(row as Session) val listener = View.OnClickListener { @@ -573,7 +599,8 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a transaction view */ - inner class RowTransactionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class RowTransactionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { itemView.transactionRow.setData(row as Transaction) val listener = View.OnClickListener { @@ -586,14 +613,16 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a top 10 row */ - inner class RowTop10ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class RowTop10ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { if (row is Session) { 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() + val formattedStat = + ComputedStat(Stat.NET_RESULT, result, currency = row.currency).format() gameResult.setTextFormat(formattedStat, itemView.context) } @@ -602,15 +631,19 @@ enum class RowViewType(private var layoutRes: Int) { } // Duration - val durationIcon = itemView.findViewById(R.id.sessionInfoDurationIcon) - val durationText = itemView.findViewById(R.id.sessionInfoDuration) + val durationIcon = + itemView.findViewById(R.id.sessionInfoDurationIcon) + val durationText = + itemView.findViewById(R.id.sessionInfoDuration) durationIcon?.isVisible = true durationText?.isVisible = true durationText?.text = row.getFormattedDuration() // Location - val locationIcon = itemView.findViewById(R.id.sessionInfoLocationIcon) - val locationText = itemView.findViewById(R.id.sessionInfoLocation) + val locationIcon = + itemView.findViewById(R.id.sessionInfoLocationIcon) + val locationText = + itemView.findViewById(R.id.sessionInfoLocation) if (!row.location?.name.isNullOrEmpty()) { locationIcon?.isVisible = true @@ -622,8 +655,10 @@ enum class RowViewType(private var layoutRes: Int) { } // Table Size - val tableSizeIcon = itemView.findViewById(R.id.sessionInfoTableSizeIcon) - val tableSizeText = itemView.findViewById(R.id.sessionInfoTableSize) + val tableSizeIcon = + itemView.findViewById(R.id.sessionInfoTableSizeIcon) + val tableSizeText = + itemView.findViewById(R.id.sessionInfoTableSize) row.tableSize?.let { tableSizeIcon?.isVisible = true @@ -646,7 +681,8 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a player image view */ - inner class RowPlayerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class RowPlayerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { if (row is Player) { @@ -672,7 +708,8 @@ enum class RowViewType(private var layoutRes: Int) { /** * Display a player image view */ - inner class RowPlayerImageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { + inner class RowPlayerImageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + BindableHolder { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { itemView.findViewById(R.id.playerImageView)?.let { playerImageView -> val listener = View.OnClickListener { @@ -692,22 +729,64 @@ enum class RowViewType(private var layoutRes: Int) { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { val computedAction = row as ComputedAction - itemView.findViewById