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 105377db..13ed3963 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 @@ -10,6 +10,9 @@ import android.widget.Button import android.widget.EditText import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView +import kotlinx.android.synthetic.main.row_hhsettings_blinds.view.* +import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.* +import kotlinx.android.synthetic.main.row_hhsettings_straddle.view.* import net.pokeranalytics.android.R import net.pokeranalytics.android.exceptions.PAIllegalStateException import net.pokeranalytics.android.model.handhistory.Street @@ -32,7 +35,12 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier { HEADER(R.layout.row_header_value), ACTION(R.layout.row_hand_action), PLAYER_SUMMARY(R.layout.row_hand_player_summary), - STREET(R.layout.row_hand_cards); + STREET(R.layout.row_hand_cards), + BLINDS(R.layout.row_hhsettings_blinds), + STRADDLE(R.layout.row_hhsettings_straddle), +// COMMENT(R.layout.row_hhsettings_comment), + PLAYER_SETUP(R.layout.row_hhsettings_player_setup) + ; override val identifier: Int get() { return this.ordinal } @@ -56,6 +64,9 @@ class HandHistoryAdapter( HandRowType.ACTION -> RowHandAction(layout) HandRowType.STREET -> RowHandStreet(layout) HandRowType.PLAYER_SUMMARY -> RowHandPlayerSummary(layout) + HandRowType.BLINDS -> RowHandBlinds(layout) + HandRowType.STRADDLE -> RowHandStraddle(layout) + HandRowType.PLAYER_SETUP -> RowHandPlayerSetup(layout) } } @@ -350,4 +361,61 @@ class HandHistoryAdapter( } } + inner class RowHandBlinds(itemView: View) : RowHandHolder(itemView) { + + // sb, bb, ante, bb ante + + override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { + super.onBind(position, row, adapter) + + itemView.smallBlindEditText.setText(adapter.dataSource.stringForRow(row)) + itemView.bigBlindEditText.setText(adapter.dataSource.stringForRow(row)) + itemView.anteEditText.setText(adapter.dataSource.stringForRow(row)) + itemView.bbAnteSwitch.isChecked = adapter.dataSource.isSelected(position, row, 0) + } + + } + + inner class RowHandStraddle(itemView: View) : RowHandHolder(itemView) { + + override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { + super.onBind(position, row, adapter) + +// itemView.typeChipGroup.clearCheck() + + itemView.typeChipGroup.setOnCheckedChangeListener { chipGroup, i -> + + } + + val hadStraddle = adapter.dataSource.isSelectable(row) + val countVisibility = if (hadStraddle) View.VISIBLE else View.GONE + + itemView.countTextView.visibility = countVisibility + itemView.minusButton.visibility = countVisibility + itemView.plusButton.visibility = countVisibility + + itemView.countTextView.text = adapter.dataSource.stringForRow(row) + + } + // type: none, std, mississipi + // number + + } + + inner class RowHandPlayerSetup(itemView: View) : RowHandHolder(itemView) { + + override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { + super.onBind(position, row, adapter) + +// itemView.positionsChipGroup + + itemView.handEditText.setText(adapter.dataSource.stringForRow(row)) + itemView.stackEditText.setText(adapter.dataSource.stringForRow(row)) + + } + + // position, stack, hand + + } + } \ No newline at end of file diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt index 058664d1..62a92ade 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt @@ -53,7 +53,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - model = activity?.run { + this.model = activity?.run { ViewModelProviders.of(this)[HandHistoryViewModel::class.java] } ?: throw Exception("Invalid Activity") @@ -237,7 +237,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL this.model.currentAmount = value as String } - // Keyboard Listener override fun actionSelected(action: Action.Type) { diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistorySettings.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistorySettings.kt new file mode 100644 index 00000000..19db5dd3 --- /dev/null +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistorySettings.kt @@ -0,0 +1,12 @@ +package net.pokeranalytics.android.ui.modules.handhistory.model + +import net.pokeranalytics.android.ui.view.RowRepresentable + +enum class HandHistorySettings : RowRepresentable { + BASE, + STRADDLE, + COMMENT, + PLAYER_SETUP; + + +} \ No newline at end of file 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 afaa670d..323a9623 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 @@ -126,6 +126,71 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra this.createRowRepresentation() } + /*** + * Uses the action list to create the list of RowRepresentables, displayed to the user + */ + private fun createRowRepresentation() { + val rows: MutableList = mutableListOf() + + rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = "")) + + + + + + + Street.values().forEach { street -> + + val actions = this.sortedActions.filter { it.street == street } + + when (street) { + Street.SUMMARY -> { + val lastActionIndex = this.sortedActions.size - 1 + + if (this.sortedActions.activePositions(lastActionIndex).size < 2 || this.sortedActions.isStreetActionClosed(lastActionIndex) == Street.SUMMARY) { + addStreetHeader(rows, street) + + val positions = this.sortedActions.activePositions(lastActionIndex, true) + positions.forEach { + val positionIndex = this.sortedActions.positions.indexOf(it) + val playerCardsRow = PlayerCardsRow(it, this.handHistory.playerSetupForPosition(positionIndex), this.playerHandMaxCards) + rows.add(playerCardsRow) + } + } + } + else -> { + if (actions.isNotEmpty()) { + addStreetHeader(rows, street) + rows.addAll(actions) + } + } + } + } + this.rowsLiveData.value = rows + } + + /*** + * Adds a [street] header to a [rowRepresentables] + */ + private fun addStreetHeader(rowRepresentables: MutableList, street: Street) { + + val firstIndexOfStreet = this.sortedActions.firstOrNull { it.street == street }?.action?.index + ?: this.sortedActions.size + + val potSize = this.sortedActions.take(firstIndexOfStreet).sumByDouble { it.action.effectiveAmount } + val potString = if (potSize > 0) potSize.formatted() else "" // "" required otherwise random values come up + + val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId, value = potString) + rowRepresentables.add(headerView) + + if (street.totalBoardCards > 0) { + // create new StreetCardsRow + val boardView = StreetCardsRow(street, this.handHistory) + rowRepresentables.add(boardView) + } + + } + /*** * Sets the number of players playing the hand * Defines the appropriate positions for this player count @@ -150,7 +215,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra } /*** - * Returns a list of positions that needs to act [index] + * Returns a list of positions that needs to act */ fun positionsToAct(): List { return this.sortedActions.positionsToActAfterIndex(this.actionIndexForSelection) @@ -305,65 +370,6 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra } - /*** - * Uses the action list to create the list of RowRepresentables, displayed to the user - */ - private fun createRowRepresentation() { - val rows: MutableList = mutableListOf() - - rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = "")) - - Street.values().forEach { street -> - - val actions = this.sortedActions.filter { it.street == street } - - when (street) { - Street.SUMMARY -> { - val lastActionIndex = this.sortedActions.size - 1 - - if (this.sortedActions.activePositions(lastActionIndex).size < 2 || this.sortedActions.isStreetActionClosed(lastActionIndex) == Street.SUMMARY) { - addStreetHeader(rows, street) - - val positions = this.sortedActions.activePositions(lastActionIndex, true) - positions.forEach { - val positionIndex = this.sortedActions.positions.indexOf(it) - val playerCardsRow = PlayerCardsRow(it, this.handHistory.playerSetupForPosition(positionIndex), this.playerHandMaxCards) - rows.add(playerCardsRow) - } - } - } - else -> { - if (actions.isNotEmpty()) { - addStreetHeader(rows, street) - rows.addAll(actions) - } - } - } - } - this.rowsLiveData.value = rows - } - - /*** - * Adds a [street] header to a [rowRepresentables] - */ - private fun addStreetHeader(rowRepresentables: MutableList, street: Street) { - - val firstIndexOfStreet = this.sortedActions.firstOrNull { it.street == street }?.action?.index - ?: this.sortedActions.size - - val potSize = this.sortedActions.take(firstIndexOfStreet).sumByDouble { it.action.effectiveAmount } - val potString = if (potSize > 0) potSize.formatted() else "" // "" required otherwise random values come up - - val headerView = CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = street.resId, value = potString) - rowRepresentables.add(headerView) - - if (street.totalBoardCards > 0) { - // create new StreetCardsRow - val boardView = StreetCardsRow(street, this.handHistory) - rowRepresentables.add(boardView) - } - - } // Card Centralizer diff --git a/app/src/main/res/layout/row_hhsettings_blinds.xml b/app/src/main/res/layout/row_hhsettings_blinds.xml new file mode 100644 index 00000000..ec7ffa24 --- /dev/null +++ b/app/src/main/res/layout/row_hhsettings_blinds.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/row_hhsettings_player_setup.xml b/app/src/main/res/layout/row_hhsettings_player_setup.xml new file mode 100644 index 00000000..2348baa5 --- /dev/null +++ b/app/src/main/res/layout/row_hhsettings_player_setup.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/row_hhsettings_straddle.xml b/app/src/main/res/layout/row_hhsettings_straddle.xml new file mode 100644 index 00000000..e520b718 --- /dev/null +++ b/app/src/main/res/layout/row_hhsettings_straddle.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 41fe8495..735d3daa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -791,5 +791,6 @@ c_allin r_allin + mississipi diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 1c035f62..844cc94b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -344,7 +344,6 @@ + +