|
|
|
|
@ -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) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|