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 772badcb..2435920d 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 @@ -201,12 +201,11 @@ class HandHistoryAdapter( fun editTextSelected(editText: EditText, selected: Boolean, tag: Int) { editText.setBackgroundColor(color(selected)) - val row = dataSource.rowRepresentableForPosition(currentPosition) + val row = dataSource.rowRepresentableForPosition(this.currentPosition) ?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition") - val alreadySelected = dataSource.isSelected(currentPosition, row, tag) - if (!alreadySelected && selected) { - delegate?.onRowSelected(currentPosition, row, tag) - } + + delegate?.onRowSelected(currentPosition, row, tag) + } override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { @@ -266,13 +265,13 @@ class HandHistoryAdapter( editText.setText(string) // Focus - val selected = adapter.dataSource.isSelected(position, row, tag) - toggleFocus(editText, selected) + val focused = adapter.dataSource.isSelected(position, row, tag) + toggleFocus(editText, focused) editText.isFocusable = adapter.dataSource.isFocusable(position, row, tag) editText.isFocusableInTouchMode = adapter.dataSource.isFocusable(position, row, tag) // Background - editText.setBackgroundColor(color(selected)) + editText.setBackgroundColor(color(focused)) } @@ -298,6 +297,11 @@ class HandHistoryAdapter( itemView.smallBlindEditText.tag = 0 itemView.bigBlindEditText.tag = 1 itemView.anteEditText.tag = 2 + + setClickListener(itemView.smallBlindEditText) + setClickListener(itemView.bigBlindEditText) + setClickListener(itemView.anteEditText) + } // sb, bb, ante, bb ante 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 f3114f6f..74d762cb 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 @@ -210,7 +210,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL Timber.d("onRowSelected: $position, tag = $tag, row = $row") - if (!this.model.isEdited) { + val alreadySelected = this.model.isSelected(position, row, tag) + if (alreadySelected || !this.model.isEdited) { return } @@ -362,11 +363,13 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL this.keyboard.setPositions(positions) } + /*** + * Closes the keyboard and removes any selection + */ override fun closeKeyboard() { - this.model.selectionLiveData.value?.index?.let { - this.handHistoryAdapter.notifyItemChanged(it) - this.model.selectionLiveData.value = null - } + val currentIndex = this.model.currentSelection.index + this.model.selectionLiveData.value = null + this.handHistoryAdapter.notifyItemChanged(currentIndex) this.keyboard?.hide() } 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 d89cd778..b3e138e8 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 @@ -176,9 +176,10 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra rows.add(HandRowType.PLAYER_NUMBER) rows.add(HandRowType.BLINDS) - if (this.isNew) { // don't allow any straddle changes if not new + val positions = Position.positionsPerPlayers(this.handHistory.numberOfPlayers) + if (this.isNew && positions.size > 2) { // don't allow any straddle changes if not new, or if it's a headsup - val positions = Position.positionsPerPlayers(this.handHistory.numberOfPlayers) + rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.straddle)) positions.remove(Position.SB) positions.remove(Position.BB) rows.add(StraddleRowRepresentable(positions, this.straddlePositions)) @@ -576,6 +577,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra override fun isFocusable(position: Int, row: RowRepresentable, tag: Int): Boolean { return when (row) { + HandRowType.BLINDS -> this.isSelected(position, row, tag) is ComputedAction -> { val isSelected = this.isSelected(position, row, tag) when (tag) {