|
|
|
|
@ -240,6 +240,15 @@ class HandHistoryAdapter( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun setOnItemClickListener(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?.onItemClick(currentPosition, row, button.tag as Int) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun toggleFocus(editText: EditText, focused: Boolean) { |
|
|
|
|
if (focused) { |
|
|
|
|
editText.requestFocus() |
|
|
|
|
@ -444,6 +453,35 @@ class HandHistoryAdapter( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
abstract inner class AbstractRowHandPlayerSetup(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
|
|
|
|
|
protected var delegate: RowRepresentableDelegate? = null |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.ps_hand_layout.tag = PlayerSetupRow.Tag.HAND.ordinal |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
super.onBind(position, row, adapter) |
|
|
|
|
|
|
|
|
|
val setupRow = row as PlayerSetupRow |
|
|
|
|
val state = setupRow.state |
|
|
|
|
this.delegate = adapter.delegate |
|
|
|
|
|
|
|
|
|
// Position Button |
|
|
|
|
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.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.ps_hand_layout) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowHandReadOnlyPlayerSetup(itemView: View) : AbstractRowHandPlayerSetup(itemView) { |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
@ -466,7 +504,6 @@ class HandHistoryAdapter( |
|
|
|
|
init { |
|
|
|
|
|
|
|
|
|
itemView.ps_player_button.tag = PlayerSetupRow.Tag.PLAYER.ordinal |
|
|
|
|
|
|
|
|
|
setOnClickListener(itemView.ps_player_button) |
|
|
|
|
|
|
|
|
|
itemView.stack_edit_text.tag = PlayerSetupRow.Tag.STACK.ordinal |
|
|
|
|
@ -509,33 +546,4 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
abstract inner class AbstractRowHandPlayerSetup(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
|
|
|
|
|
protected var delegate: RowRepresentableDelegate? = null |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.ps_hand_layout.tag = PlayerSetupRow.Tag.HAND.ordinal |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
super.onBind(position, row, adapter) |
|
|
|
|
|
|
|
|
|
val setupRow = row as PlayerSetupRow |
|
|
|
|
val state = setupRow.state |
|
|
|
|
this.delegate = adapter.delegate |
|
|
|
|
|
|
|
|
|
// Position Button |
|
|
|
|
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.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.ps_hand_layout) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |