From c05f97df2df644f31be73e7650e497db522ca033 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 21 Feb 2020 07:59:05 +0100 Subject: [PATCH] Fixes board selection issue --- .../android/ui/modules/handhistory/HandHistoryAdapter.kt | 4 ---- .../android/ui/modules/handhistory/model/CardsRow.kt | 7 +++++-- .../ui/modules/handhistory/model/HandHistoryViewModel.kt | 9 ++------- app/src/main/res/layout/row_hand_cards.xml | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) 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 412e3e53..50c47e1c 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 @@ -442,10 +442,6 @@ class HandHistoryAdapter( */ inner class RowHandStreet(itemView: View) : RowHandHolder(itemView) { - init { - - } - override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { super.onBind(position, row, adapter) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/CardsRow.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/CardsRow.kt index 49de74ac..42e66a64 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/CardsRow.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/CardsRow.kt @@ -27,7 +27,10 @@ abstract class CardsRow : HandHistoryRow { abstract val cardHolder: CardHolder? override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean { - return this.canAddMoreCards() + this.cardLimit()?.let { limit -> + return !(this.cardCount >= limit && lastCard()?.suit != null) + } + return true } override fun keyboardForTag(tag: Int): HHKeyboard? { @@ -107,7 +110,7 @@ abstract class CardsRow : HandHistoryRow { protected open fun canAddMoreCards(): Boolean { this.cardLimit()?.let { limit -> - return !(this.cardCount >= limit && lastCard()?.suit != null) + return this.cardCount < limit } return true } 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 90afd482..36f1ebf3 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 @@ -487,7 +487,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra * When a card selection is ended, * sets the playerHandMaxCards with the number of cards set to the player */ - private fun cardSelectionEnded(index: Int) { + fun cardSelectionEnded() { + val index = this.currentSelection.index val cardsRow = this.rowRepresentables[index] as CardsRow if (cardsRow is PlayerCardsRow) { this.playerHandMaxCards = cardsRow.cardCount @@ -699,12 +700,6 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra return listOf() } - /*** - * Ends the card selection - */ - fun cardSelectionEnded() { - this.cardSelectionEnded(this.currentSelection.index) - } /*** * Defines the positions having straddled and diff --git a/app/src/main/res/layout/row_hand_cards.xml b/app/src/main/res/layout/row_hand_cards.xml index ca9234cb..705444d4 100644 --- a/app/src/main/res/layout/row_hand_cards.xml +++ b/app/src/main/res/layout/row_hand_cards.xml @@ -1,7 +1,7 @@