Fixes board selection issue

hh
Laurent 6 years ago
parent 2a00e529d5
commit c05f97df2d
  1. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  2. 7
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/CardsRow.kt
  3. 9
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  4. 2
      app/src/main/res/layout/row_hand_cards.xml

@ -442,10 +442,6 @@ class HandHistoryAdapter(
*/ */
inner class RowHandStreet(itemView: View) : RowHandHolder(itemView) { inner class RowHandStreet(itemView: View) : RowHandHolder(itemView) {
init {
}
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)

@ -27,7 +27,10 @@ abstract class CardsRow : HandHistoryRow {
abstract val cardHolder: CardHolder? abstract val cardHolder: CardHolder?
override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean { 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? { override fun keyboardForTag(tag: Int): HHKeyboard? {
@ -107,7 +110,7 @@ abstract class CardsRow : HandHistoryRow {
protected open fun canAddMoreCards(): Boolean { protected open fun canAddMoreCards(): Boolean {
this.cardLimit()?.let { limit -> this.cardLimit()?.let { limit ->
return !(this.cardCount >= limit && lastCard()?.suit != null) return this.cardCount < limit
} }
return true return true
} }

@ -487,7 +487,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
* When a card selection is ended, * When a card selection is ended,
* sets the playerHandMaxCards with the number of cards set to the player * 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 val cardsRow = this.rowRepresentables[index] as CardsRow
if (cardsRow is PlayerCardsRow) { if (cardsRow is PlayerCardsRow) {
this.playerHandMaxCards = cardsRow.cardCount this.playerHandMaxCards = cardsRow.cardCount
@ -699,12 +700,6 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
return listOf() return listOf()
} }
/***
* Ends the card selection
*/
fun cardSelectionEnded() {
this.cardSelectionEnded(this.currentSelection.index)
}
/*** /***
* Defines the positions having straddled and * Defines the positions having straddled and

@ -1,7 +1,7 @@
<?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="horizontal" android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_width="148dp"
android:layout_height="50dp" android:layout_height="50dp"
android:background="@drawable/rounded_board_background" android:background="@drawable/rounded_board_background"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"

Loading…
Cancel
Save