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 c2db9382..21e4765d 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 @@ -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(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