|
|
|
@ -110,21 +110,13 @@ class HandHistoryAdapter( |
|
|
|
inner class RowHandAction(itemView: View) : RowHandHolder(itemView), |
|
|
|
inner class RowHandAction(itemView: View) : RowHandHolder(itemView), |
|
|
|
BindableHolder { |
|
|
|
BindableHolder { |
|
|
|
|
|
|
|
|
|
|
|
// private var listener = TextListener() |
|
|
|
|
|
|
|
private var actionCanBeEdited = true |
|
|
|
|
|
|
|
private var amountCanBeEdited = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
init { |
|
|
|
// Action |
|
|
|
// Action |
|
|
|
itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton -> |
|
|
|
itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton -> |
|
|
|
|
|
|
|
|
|
|
|
actionButton.setOnClickListener { |
|
|
|
actionButton.setOnClickListener { |
|
|
|
|
|
|
|
|
|
|
|
if (this.actionCanBeEdited) { |
|
|
|
|
|
|
|
buttonEdited(actionButton, true, HHKeyboard.ACTION.ordinal) |
|
|
|
buttonEdited(actionButton, true, HHKeyboard.ACTION.ordinal) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Amount |
|
|
|
// Amount |
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
@ -133,8 +125,6 @@ class HandHistoryAdapter( |
|
|
|
amountEditText.isFocusableInTouchMode = true |
|
|
|
amountEditText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
|
|
amountEditText.setOnTouchListener { _, event -> |
|
|
|
amountEditText.setOnTouchListener { _, event -> |
|
|
|
// Timber.d("touch action = ${event.action}") |
|
|
|
|
|
|
|
if (this.amountCanBeEdited) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
@ -145,7 +135,6 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
|
|
editTextSelected(amountEditText, true, HHKeyboard.AMOUNT.ordinal) |
|
|
|
editTextSelected(amountEditText, true, HHKeyboard.AMOUNT.ordinal) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return@setOnTouchListener true |
|
|
|
return@setOnTouchListener true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -171,8 +160,6 @@ class HandHistoryAdapter( |
|
|
|
this.currentPosition = position |
|
|
|
this.currentPosition = position |
|
|
|
|
|
|
|
|
|
|
|
val computedAction = row as ComputedAction |
|
|
|
val computedAction = row as ComputedAction |
|
|
|
this.actionCanBeEdited = computedAction.actionTypeCanBeEdited |
|
|
|
|
|
|
|
this.amountCanBeEdited = computedAction.amountCanBeEdited |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Position |
|
|
|
// Position |
|
|
|
itemView.findViewById<Button>(R.id.positionButton)?.let { button -> |
|
|
|
itemView.findViewById<Button>(R.id.positionButton)?.let { button -> |
|
|
|
@ -181,14 +168,16 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
|
|
// Action |
|
|
|
// Action |
|
|
|
itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton -> |
|
|
|
itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton -> |
|
|
|
|
|
|
|
actionButton.isEnabled = computedAction.actionTypeCanBeEdited |
|
|
|
|
|
|
|
|
|
|
|
val tag = HHKeyboard.ACTION.ordinal |
|
|
|
val tag = HHKeyboard.ACTION.ordinal |
|
|
|
|
|
|
|
|
|
|
|
val selected = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
val selected = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
// Timber.d("Action at $position is selected: $selected") |
|
|
|
// Timber.d("Action at $position is selected: $selected") |
|
|
|
actionButton.backgroundTintList = ColorStateList.valueOf(color(selected)) |
|
|
|
actionButton.backgroundTintList = ColorStateList.valueOf(color(selected)) |
|
|
|
if (selected) { |
|
|
|
// if (selected) { |
|
|
|
(itemView.context as Activity).hideKeyboard() |
|
|
|
// (itemView.context as Activity).hideKeyboard() |
|
|
|
} |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
computedAction.action.type?.resId?.let { |
|
|
|
computedAction.action.type?.resId?.let { |
|
|
|
actionButton.setText(it) |
|
|
|
actionButton.setText(it) |
|
|
|
@ -200,6 +189,8 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
|
|
// Amount |
|
|
|
// Amount |
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
|
|
|
|
amountEditText.isEnabled = computedAction.amountCanBeEdited |
|
|
|
|
|
|
|
|
|
|
|
val tag = HHKeyboard.AMOUNT.ordinal |
|
|
|
val tag = HHKeyboard.AMOUNT.ordinal |
|
|
|
|
|
|
|
|
|
|
|
val selected = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
val selected = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
|