|
|
|
|
@ -12,13 +12,13 @@ import androidx.core.view.isVisible |
|
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.formatted |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.BindableHolder |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RecyclerAdapter |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.model.HHKeyboard |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.views.PlayerCardsRow |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.views.StreetCardsRow |
|
|
|
|
@ -102,26 +102,6 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowHandActionTest(itemView: View) : RowHandHolder(itemView), BindableHolder { |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
|
|
|
|
|
val computedAction = row as ComputedAction |
|
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
|
// amountEditText.setText(computedAction.action.formattedAmount) |
|
|
|
|
|
|
|
|
|
val selected = adapter.dataSource.isSelected(position, row, 0) |
|
|
|
|
if (selected) { |
|
|
|
|
amountEditText.requestFocus() |
|
|
|
|
} else { |
|
|
|
|
amountEditText.clearFocus() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Display a hand action |
|
|
|
|
*/ |
|
|
|
|
@ -262,8 +242,8 @@ class HandHistoryAdapter( |
|
|
|
|
flopEditText.isFocusable = (street == Street.FLOP) |
|
|
|
|
|
|
|
|
|
flopEditText.isVisible = true |
|
|
|
|
val flop = streetCardView.cards.take(3) |
|
|
|
|
val text = flop.formatted(itemView.context) |
|
|
|
|
val flop = streetCardView.cardHolder?.cards?.take(3) |
|
|
|
|
val text = flop?.formatted(itemView.context) |
|
|
|
|
flopEditText.setText(text) |
|
|
|
|
|
|
|
|
|
val selected = adapter.dataSource.isSelected(position, row, Street.FLOP.ordinal) |
|
|
|
|
@ -275,8 +255,8 @@ class HandHistoryAdapter( |
|
|
|
|
// turnEditText.isVisible = streetCardView.street.ordinal >= Street.TURN.ordinal |
|
|
|
|
turnEditText.isFocusable = (street == Street.TURN) |
|
|
|
|
|
|
|
|
|
if (streetCardView.cards.size >= 4) { |
|
|
|
|
val text = streetCardView.cards[3].formatted(itemView.context) |
|
|
|
|
if (streetCardView.cardCount > 3) { |
|
|
|
|
val text = streetCardView.cardAtIndex(3)?.formatted(itemView.context) |
|
|
|
|
turnEditText.setText(text) |
|
|
|
|
} else { |
|
|
|
|
turnEditText.text = null |
|
|
|
|
@ -290,8 +270,8 @@ class HandHistoryAdapter( |
|
|
|
|
// riverEditText.isVisible = streetCardView.street.ordinal >= Street.RIVER.ordinal |
|
|
|
|
riverEditText.isFocusable = (street == Street.RIVER) |
|
|
|
|
|
|
|
|
|
if (streetCardView.cards.size >= 5) { |
|
|
|
|
val text = streetCardView.cards[4].formatted(itemView.context) |
|
|
|
|
if (streetCardView.cardCount > 4) { |
|
|
|
|
val text = streetCardView.cardAtIndex(4)?.formatted(itemView.context) |
|
|
|
|
riverEditText.setText(text) |
|
|
|
|
} else { |
|
|
|
|
riverEditText.text = null |
|
|
|
|
@ -350,24 +330,24 @@ class HandHistoryAdapter( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Amount |
|
|
|
|
itemView.findViewById<EditText>(R.id.cardsEditText)?.let { amountEditText -> |
|
|
|
|
itemView.findViewById<EditText>(R.id.cardsEditText)?.let { cardsEditText -> |
|
|
|
|
val tag = HHKeyboard.AMOUNT.ordinal |
|
|
|
|
|
|
|
|
|
val selected = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
|
|
|
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
|
amountEditText.isFocusable = selected |
|
|
|
|
amountEditText.isFocusableInTouchMode = selected |
|
|
|
|
cardsEditText.isFocusable = selected |
|
|
|
|
cardsEditText.isFocusableInTouchMode = selected |
|
|
|
|
|
|
|
|
|
Timber.d("Amount at $position is selected: $selected, focusable = ${amountEditText.isFocusable}, isFocusableInTouchMode = ${amountEditText.isFocusableInTouchMode}, hasFocus = ${amountEditText.hasFocus()}, enabled = ${amountEditText.isEnabled}") |
|
|
|
|
amountEditText.setBackgroundColor(color(selected)) |
|
|
|
|
Timber.d("Amount at $position is selected: $selected, focusable = ${cardsEditText.isFocusable}, isFocusableInTouchMode = ${cardsEditText.isFocusableInTouchMode}, hasFocus = ${cardsEditText.hasFocus()}, enabled = ${cardsEditText.isEnabled}") |
|
|
|
|
cardsEditText.setBackgroundColor(color(selected)) |
|
|
|
|
|
|
|
|
|
amountEditText.setText(playerCardView.cards.formatted(itemView.context)) |
|
|
|
|
cardsEditText.setText(playerCardView.cardHolder?.cards?.formatted(itemView.context)) |
|
|
|
|
|
|
|
|
|
if (selected) { |
|
|
|
|
amountEditText.requestFocus() |
|
|
|
|
cardsEditText.requestFocus() |
|
|
|
|
} else { |
|
|
|
|
amountEditText.clearFocus() |
|
|
|
|
cardsEditText.clearFocus() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|