Fixing player setups read only issue + read rows improvement

hh
Laurent 6 years ago
parent 774ae12f6f
commit bc21a39e9a
  1. 65
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  2. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardActionView.kt
  4. 2
      app/src/main/res/layout/row_hand_action.xml
  5. 2
      app/src/main/res/layout/row_hand_action_read.xml
  6. 2
      app/src/main/res/layout/row_hand_player_summary.xml
  7. 10
      app/src/main/res/layout/row_hhsettings_player_setup.xml
  8. 6
      app/src/main/res/layout/row_hhsettings_player_setup_read.xml
  9. 4
      app/src/main/res/layout/view_hand_keyboard_action.xml

@ -18,8 +18,8 @@ import kotlinx.android.synthetic.main.row_hand_action_read.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_player_setup.view.*
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.posButton
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.psHandLayout
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.position_button
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.ps_hand_layout
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.settings_container
import kotlinx.android.synthetic.main.row_hhsettings_player_setup_read.view.*
import kotlinx.android.synthetic.main.row_hhsettings_straddle.view.*
@ -147,7 +147,7 @@ class HandHistoryAdapter(
abstract inner class RowHandHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder {
protected var currentPosition = 0
private var currentPosition = 0
fun color(isFocused: Boolean) : Int {
val color = if (isFocused) R.color.kaki_medium else R.color.kaki
@ -160,7 +160,7 @@ class HandHistoryAdapter(
val row = dataSource.rowRepresentableForPosition(this.currentPosition)
?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition")
delegate?.onRowSelected(currentPosition, row, tag)
delegate?.onRowSelected(this.currentPosition, row, tag)
}
@ -206,7 +206,7 @@ class HandHistoryAdapter(
}
protected fun configureTextView(tag: Int, position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
protected fun configureTextView(tag: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
val textView = itemView.findViewWithTag<TextView>(tag) ?: throw PAIllegalStateException("TextView not found for tag: $tag, class: $this")
textView.text = adapter.dataSource.charSequenceForRow(row, itemView.context, tag)
}
@ -231,6 +231,15 @@ class HandHistoryAdapter(
}
protected fun setOnClickListener(button: Button) {
button.setOnClickListener {
button.backgroundTintList = ColorStateList.valueOf(color(true))
val row = dataSource.rowRepresentableForPosition(currentPosition)
?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition")
delegate?.onRowSelected(currentPosition, row, button.tag as Int)
}
}
private fun toggleFocus(editText: EditText, focused: Boolean) {
if (focused) {
editText.requestFocus()
@ -310,15 +319,19 @@ class HandHistoryAdapter(
itemView.amountEditText.tag = ComputedAction.Tag.AMOUNT.ordinal
// Action
itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton ->
actionButton.setOnClickListener {
actionButton.backgroundTintList = ColorStateList.valueOf(color(true))
val row = dataSource.rowRepresentableForPosition(currentPosition)
?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition")
delegate?.onRowSelected(currentPosition, row, HHKeyboard.ACTION.ordinal)
}
}
setOnClickListener(itemView.actionButton)
// itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton ->
//
// setOnClickListener(actionButton)
// actionButton.setOnClickListener {
// actionButton.backgroundTintList = ColorStateList.valueOf(color(true))
//
// val row = dataSource.rowRepresentableForPosition(currentPosition)
// ?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition")
// delegate?.onRowSelected(currentPosition, row, HHKeyboard.ACTION.ordinal)
// }
// }
// Amount
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText ->
@ -383,7 +396,7 @@ class HandHistoryAdapter(
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
val actionReadRow = row as ActionReadRow
itemView.playersText.text = actionReadRow.positions.map { it.value }.joinToString(", ")
itemView.playersText.text = actionReadRow.positions.joinToString(", ") { it.value }
itemView.actionText.text = actionReadRow.action?.localizedTitle(itemView.context)
itemView.amountText.text = actionReadRow.amount?.formatted()
@ -440,7 +453,7 @@ class HandHistoryAdapter(
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
super.onBind(position, row, adapter)
configureTextView(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter)
configureTextView(PlayerSetupRow.Tag.STACK.ordinal, row, adapter)
}
}
@ -452,13 +465,15 @@ class HandHistoryAdapter(
init {
itemView.stackEditText.tag = PlayerSetupRow.Tag.STACK.ordinal
itemView.stackEditText.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL
setClickListener(itemView.stackEditText)
setOnClickListener(itemView.ps_player_button)
itemView.stack_edit_text.tag = PlayerSetupRow.Tag.STACK.ordinal
itemView.stack_edit_text.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL
setClickListener(itemView.stack_edit_text)
this.positionViewManager = LinearLayoutManager(itemView.context, RecyclerView.HORIZONTAL, false)
itemView.positionRecyclerView.apply {
itemView.position_recycler.apply {
setHasFixedSize(true)
layoutManager = positionViewManager
adapter = positionAdapter
@ -478,7 +493,7 @@ class HandHistoryAdapter(
// Position recycler
val posVisibility = if (state == PlayerSetupRow.State.SETUP_ONLY) View.GONE else View.VISIBLE
itemView.positionRecyclerView.visibility = posVisibility
itemView.position_recycler.visibility = posVisibility
this.positionAdapter.positions = adapter.dataSource.contentForRow(row, itemView.context, Position::class)
this.positionAdapter.setOnClickListener { pos ->
@ -497,7 +512,7 @@ class HandHistoryAdapter(
protected var delegate: RowRepresentableDelegate? = null
init {
itemView.psHandLayout.tag = PlayerSetupRow.Tag.HAND.ordinal
itemView.ps_hand_layout.tag = PlayerSetupRow.Tag.HAND.ordinal
}
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
@ -508,14 +523,14 @@ class HandHistoryAdapter(
this.delegate = adapter.delegate
// Position Button
itemView.posButton.text = adapter.dataSource.charSequenceForRow(row, itemView.context, PlayerSetupRow.Tag.POSITION.ordinal)
itemView.position_button.text = adapter.dataSource.charSequenceForRow(row, itemView.context, PlayerSetupRow.Tag.POSITION.ordinal)
val positionSelected = adapter.dataSource.isSelected(position, row, PlayerSetupRow.Tag.POSITION.ordinal)
itemView.posButton.backgroundTintList = ColorStateList.valueOf(color(positionSelected))
itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionSelected))
// Settings
itemView.settings_container.visibility = if (state == PlayerSetupRow.State.POSITIONS_ONLY) View.GONE else View.VISIBLE
configureCardsLayout(itemView.psHandLayout)
configureCardsLayout(itemView.ps_hand_layout)
}

@ -209,9 +209,11 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = ""))
rows.add(HandRowType.PLAYER_NUMBER)
if (this.handHistory.ante > 0) {
rows.add(HandRowType.ANTE)
}
if (this.handSetup.type != Session.Type.CASH_GAME) {
if (this.handHistory.bigBlindAnte) {
rows.add(HandRowType.BIG_BLIND_ANTE)
}

@ -61,7 +61,7 @@ class KeyboardActionView(context: Context) : AbstractKeyboardView(context),
this.positionAdapter = PositionAdapter(it)
} ?: throw PAIllegalStateException("keyboard listener not set")
this.positionRecyclerView.apply {
this.position_recycler.apply {
setHasFixedSize(true)
layoutManager = positionViewManager
adapter = positionAdapter

@ -5,7 +5,7 @@
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/playerButton"
android:id="@+id/player_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"

@ -6,7 +6,7 @@
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/playerButton"
android:id="@+id/player_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"

@ -5,7 +5,7 @@
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/playerButton"
android:id="@+id/player_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"

@ -13,7 +13,7 @@
android:layout_marginStart="8dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/positionRecyclerView"
android:id="@+id/position_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
@ -24,21 +24,21 @@
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/playerButton"
android:id="@+id/ps_player_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginStart="8dp"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/posButton"
android:id="@+id/position_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginStart="8dp"/>
<LinearLayout
android:id="@+id/psHandLayout"
android:id="@+id/ps_hand_layout"
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="50dp"
@ -50,7 +50,7 @@
android:gravity="center"/>
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/stackEditText"
android:id="@+id/stack_edit_text"
style="@style/PokerAnalyticsTheme.EditText"
android:hint="@string/stack"
android:layout_width="0dp"

@ -7,21 +7,21 @@
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/playerButton"
android:id="@+id/player_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginStart="8dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/posButton"
android:id="@+id/position_button"
style="@style/PokerAnalyticsTheme.HHButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginStart="8dp" />
<LinearLayout
android:id="@+id/psHandLayout"
android:id="@+id/ps_hand_layout"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="16dp"

@ -26,7 +26,7 @@
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/positionRecyclerView"
android:id="@+id/position_recycler"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -40,7 +40,7 @@
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/positionRecyclerView"
app:layout_constraintTop_toBottomOf="@id/position_recycler"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"

Loading…
Cancel
Save