diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/PlayerSetup.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/PlayerSetup.kt index 27839c77..66a9fe51 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/PlayerSetup.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/PlayerSetup.kt @@ -28,12 +28,12 @@ open class PlayerSetup : RealmObject(), */ override var cards: RealmList = RealmList() - fun cardValueSelected(value: Card.Value) { - - } - - fun cardSuitSelected(suit: Card.Suit) { - - } +// fun cardValueSelected(value: Card.Value) { +// +// } +// +// fun cardSuitSelected(suit: Card.Suit) { +// +// } } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt index 2fc06703..6d4f1f0f 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt @@ -133,10 +133,16 @@ interface DisplayableDataSource { // return "" // } + /*** + * Returns a CharSequence representation of the [row] + */ fun charSequenceForRow(row: RowRepresentable, context: Context): CharSequence { return charSequenceForRow(row, context, 0) } + /*** + * Returns a CharSequence representation of the [row] and [tag] + */ fun charSequenceForRow(row: RowRepresentable, context: Context, tag: Int = 0): CharSequence { return "" } @@ -169,10 +175,20 @@ interface DisplayableDataSource { return true } + /*** + * Returns a list of content for the [row], using a specific [clazz] + */ fun contentForRow(row: RowRepresentable, context: Context, clazz: KClass) : List { return listOf() } + /*** + * Returns if the selection of the [row] + [tag] is focusable + */ + fun isFocusable(position: Int, row: RowRepresentable, tag: Int): Boolean { + return true + } + } /** 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 1ae8d1df..2d4c1a32 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 @@ -8,12 +8,12 @@ import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.EditText -import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.chip.Chip import kotlinx.android.synthetic.main.row_hand_action.view.* import kotlinx.android.synthetic.main.row_hand_cards.view.* +import kotlinx.android.synthetic.main.row_hand_player_summary.view.* 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.* @@ -33,7 +33,6 @@ import net.pokeranalytics.android.ui.modules.handhistory.views.PositionAdapter import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.holder.RowViewHolder import net.pokeranalytics.android.ui.view.rowrepresentable.ViewIdentifier -import timber.log.Timber enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, HandHistoryRow { @@ -54,19 +53,42 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable, H override val identifier: Int get() { return this.ordinal } - override fun tagForCompletion(handHistory: HandHistory): Int? { + override fun tagsForCompletion(): List { + return when (this) { + BLINDS -> listOf(0, 1) + else -> listOf() + } + } + + override fun isFieldEmpty(tag: Int, handHistory: HandHistory): Boolean { return when (this) { BLINDS -> { - when { - handHistory.smallBlind == null -> 0 - handHistory.bigBlind == null -> 1 - else -> null + when (tag) { + 0 -> (handHistory.smallBlind == null) + 1 -> (handHistory.bigBlind == null) + else -> false } } - else -> null + else -> false } } +// override fun tagForCompletion( +// handHistory: HandHistory, +// minTag: Int? +// ): Int? { +// return when (this) { +// BLINDS -> { +// when { +// handHistory.smallBlind == null -> 0 +// handHistory.bigBlind == null -> 1 +// else -> null +// } +// } +// else -> null +// } +// } + override fun keyboardForTag(tag: Int): HHKeyboard? { return when (this) { BLINDS -> HHKeyboard.AMOUNT @@ -168,7 +190,7 @@ class HandHistoryAdapter( abstract inner class RowHandHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { - var currentPosition = 0 + protected var currentPosition = 0 fun color(isFocused: Boolean) : Int { val color = if (isFocused) R.color.kaki_medium else R.color.kaki @@ -194,21 +216,27 @@ class HandHistoryAdapter( this.configureEditTexts(index..index, position, row, adapter) } - protected fun configureEditTexts(range: IntRange, position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { + protected fun configureEditTexts(tagRange: IntRange, position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { - range.forEach { tag -> - val string = adapter.dataSource.charSequenceForRow(row, itemView.context, tag) + tagRange.forEach { tag -> + val editText = itemView.findViewWithTag(tag) ?: throw PAIllegalStateException("Edit Text not found for tag: $tag, class: $this") + + // Enabled + editText.isEnabled = adapter.dataSource.isEnabled(row, tag) // Text - val editText = itemView.findViewWithTag(tag) ?: throw PAIllegalStateException("Edit Text not found for tag: $tag, class: $this") + val string = adapter.dataSource.charSequenceForRow(row, itemView.context, tag) editText.setText(string) // Focus val selected = adapter.dataSource.isSelected(position, row, tag) toggleFocus(editText, selected) + editText.isFocusable = adapter.dataSource.isFocusable(position, row, tag) + editText.isFocusableInTouchMode = adapter.dataSource.isFocusable(position, row, tag) // Background editText.setBackgroundColor(color(selected)) + } } @@ -223,7 +251,6 @@ class HandHistoryAdapter( open fun editTextForTag(tag: Int) : EditText { return itemView.findViewWithTag(tag) -// throw PAIllegalStateException("Field at tag: $tag requires to return an EditText in order to connect the keyboard to it. Should be overridden by class : $this") } } @@ -242,21 +269,6 @@ class HandHistoryAdapter( super.onBind(position, row, adapter) configureEditTexts(0..2, position, row, adapter) - -// itemView.smallBlindEditText.setText(adapter.dataSource.charSequenceForRow(row, itemView.context, 0)) -// itemView.bigBlindEditText.setText(adapter.dataSource.charSequenceForRow(row, itemView.context, 1)) -// itemView.anteEditText.setText(adapter.dataSource.charSequenceForRow(row, itemView.context, 2)) -// itemView.bbAnteSwitch.isChecked = adapter.dataSource.isSelected(position, row, 0) -// -// val sbSelected = adapter.dataSource.isSelected(position, row, 0) -// toggleFocus(itemView.smallBlindEditText, sbSelected) -// -// val bbSelected = adapter.dataSource.isSelected(position, row, 1) -// toggleFocus(itemView.bigBlindEditText, bbSelected) -// -// val anteSelected = adapter.dataSource.isSelected(position, row, 2) -// toggleFocus(itemView.anteEditText, anteSelected) - } } @@ -337,10 +349,6 @@ class HandHistoryAdapter( } } -// override fun editTextForTag(tag: Int): EditText { -// return itemView.amountEditText -// } - override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { super.onBind(position, row, adapter) @@ -353,7 +361,8 @@ class HandHistoryAdapter( // Action itemView.findViewById