|
|
|
|
@ -160,14 +160,15 @@ class HandHistoryAdapter( |
|
|
|
|
return itemView.context.getColor(color) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun editTextSelected(editText: EditText, selected: Boolean) { |
|
|
|
|
fun editTextSelected(editText: EditText) { |
|
|
|
|
|
|
|
|
|
editText.setBackgroundColor(color(selected)) |
|
|
|
|
// editText.setBackgroundColor(color(selected)) |
|
|
|
|
val row = dataSource.rowRepresentableForPosition(this.currentPosition) |
|
|
|
|
?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition") |
|
|
|
|
|
|
|
|
|
delegate?.onRowSelected(this.currentPosition, row, editText.tag as Int) |
|
|
|
|
|
|
|
|
|
setEditTextBackground(editText, true, true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
@ -188,28 +189,38 @@ class HandHistoryAdapter( |
|
|
|
|
editText.setTextIsSelectable(true) |
|
|
|
|
|
|
|
|
|
// Enabled |
|
|
|
|
editText.isEnabled = adapter.dataSource.isEnabled(row, tag) |
|
|
|
|
val isEnabled = adapter.dataSource.isEnabled(row, tag) |
|
|
|
|
editText.isEnabled = isEnabled |
|
|
|
|
|
|
|
|
|
// Text |
|
|
|
|
val string = adapter.dataSource.charSequenceForRow(row, itemView.context, tag) |
|
|
|
|
editText.setText(string) |
|
|
|
|
|
|
|
|
|
// Focus |
|
|
|
|
val focused = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
|
toggleFocus(editText, focused) |
|
|
|
|
val isFocused = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
|
toggleFocus(editText, isFocused) |
|
|
|
|
editText.isFocusable = adapter.dataSource.isFocusable(position, row, tag) |
|
|
|
|
editText.isFocusableInTouchMode = adapter.dataSource.isFocusable(position, row, tag) |
|
|
|
|
|
|
|
|
|
// Put cursor at the end |
|
|
|
|
if (focused) { |
|
|
|
|
if (isFocused) { |
|
|
|
|
editText.setSelection(editText.text.length) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Background |
|
|
|
|
editText.setBackgroundColor(color(focused)) |
|
|
|
|
setEditTextBackground(editText, isEnabled, isFocused) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun setEditTextBackground(editText: EditText, isEnabled: Boolean, isFocused: Boolean) { |
|
|
|
|
val background = when { |
|
|
|
|
!isEnabled -> R.drawable.rounded_kaki_darkest_rect // disabled |
|
|
|
|
isFocused -> R.drawable.rounded_kaki_medium_rect // focused |
|
|
|
|
else -> R.drawable.rounded_kaki_darker_rect // default |
|
|
|
|
} |
|
|
|
|
editText.background = itemView.context.getDrawable(background) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun configureTextView(tag: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
@ -230,7 +241,7 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
editText.requestFocus() |
|
|
|
|
|
|
|
|
|
editTextSelected(editText, true) |
|
|
|
|
editTextSelected(editText) |
|
|
|
|
} |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
@ -447,7 +458,7 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
amountEditText.requestFocus() |
|
|
|
|
|
|
|
|
|
editTextSelected(amountEditText, true) |
|
|
|
|
editTextSelected(amountEditText) |
|
|
|
|
} |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
@ -551,13 +562,9 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
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)) |
|
|
|
|
|
|
|
|
|
val positionalRow = row as PositionalRow |
|
|
|
|
itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionalRow.isHero)) |
|
|
|
|
|
|
|
|
|
|