|
|
|
|
@ -3,7 +3,10 @@ package net.pokeranalytics.android.ui.modules.handhistory.editor |
|
|
|
|
import android.content.res.ColorStateList |
|
|
|
|
import android.text.InputType |
|
|
|
|
import android.view.* |
|
|
|
|
import android.widget.* |
|
|
|
|
import android.widget.Button |
|
|
|
|
import android.widget.EditText |
|
|
|
|
import android.widget.LinearLayout |
|
|
|
|
import android.widget.TextView |
|
|
|
|
import androidx.appcompat.widget.AppCompatButton |
|
|
|
|
import androidx.core.view.isEmpty |
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
@ -145,7 +148,7 @@ class EditorAdapter( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
abstract inner class RowHandHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
|
abstract inner class AbstractRowHandHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
|
|
|
|
|
|
private var currentPosition = 0 |
|
|
|
|
|
|
|
|
|
@ -195,25 +198,25 @@ class EditorAdapter( |
|
|
|
|
// hides soft input view, |
|
|
|
|
// 22/06/22: does not seem useful as - I believe - manifest activity has android:windowSoftInputMode="stateAlwaysHidden" |
|
|
|
|
editText.setTextIsSelectable(true) |
|
|
|
|
|
|
|
|
|
// Enabled |
|
|
|
|
// |
|
|
|
|
// // Enabled |
|
|
|
|
val isEnabled = adapter.dataSource.isEnabled(row, tag) |
|
|
|
|
editText.isEnabled = isEnabled |
|
|
|
|
|
|
|
|
|
// Text |
|
|
|
|
// |
|
|
|
|
// // Text |
|
|
|
|
val string = adapter.dataSource.charSequenceForRow(row, itemView.context, tag) |
|
|
|
|
editText.setText(string) |
|
|
|
|
|
|
|
|
|
// Focus |
|
|
|
|
// |
|
|
|
|
// // Focus |
|
|
|
|
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 (isFocused) { |
|
|
|
|
editText.setSelection(editText.text.length) |
|
|
|
|
} |
|
|
|
|
// 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 (isFocused) { |
|
|
|
|
// editText.setSelection(editText.text.length) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// Background |
|
|
|
|
setViewBackground(editText, isEnabled, isFocused) |
|
|
|
|
@ -242,7 +245,7 @@ class EditorAdapter( |
|
|
|
|
|
|
|
|
|
editText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
editText.setOnTouchListener { _, event -> |
|
|
|
|
editText.setOnTouchListener { view, event -> |
|
|
|
|
|
|
|
|
|
if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
|
@ -253,6 +256,8 @@ class EditorAdapter( |
|
|
|
|
|
|
|
|
|
editTextSelected(editText) |
|
|
|
|
} |
|
|
|
|
view.performClick() |
|
|
|
|
|
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -357,7 +362,7 @@ class EditorAdapter( |
|
|
|
|
layout.setOnClickListener { |
|
|
|
|
if ((dataSource as EditorViewModel).isEdited) { |
|
|
|
|
delegate?.onRowSelected(this.currentPosition, row, layout.tag as Int) |
|
|
|
|
setViewBackground(layout, true, true) |
|
|
|
|
setViewBackground(layout, isEnabled = true, isFocused = true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -367,7 +372,7 @@ class EditorAdapter( |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowStraddleHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
inner class RowStraddleHolder(itemView: View) : AbstractRowHandHolder(itemView) { |
|
|
|
|
private var container: ViewGroup = itemView.findViewById(R.id.container) |
|
|
|
|
private var positionsChipGroup: FlowLayout = itemView.findViewById(R.id.positionsChipGroup) |
|
|
|
|
|
|
|
|
|
@ -409,7 +414,7 @@ class EditorAdapter( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowPositionHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
inner class RowPositionHolder(itemView: View) : AbstractRowHandHolder(itemView) { |
|
|
|
|
private var recycler: RecyclerView = itemView.findViewById(R.id.recycler) |
|
|
|
|
|
|
|
|
|
private var positionAdapter: PositionAdapter = PositionAdapter() |
|
|
|
|
@ -445,7 +450,7 @@ class EditorAdapter( |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowActionReadHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
inner class RowActionReadHolder(itemView: View) : AbstractRowHandHolder(itemView) { |
|
|
|
|
|
|
|
|
|
private var playerImage: PlayerImageView = itemView.findViewById(R.id.player_image_rhar) |
|
|
|
|
private var stackText: TextView = itemView.findViewById(R.id.stackText) |
|
|
|
|
@ -481,7 +486,7 @@ class EditorAdapter( |
|
|
|
|
/** |
|
|
|
|
* Display a hand action |
|
|
|
|
*/ |
|
|
|
|
inner class RowActionHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
inner class RowActionHolder(itemView: View) : AbstractRowHandHolder(itemView) { |
|
|
|
|
|
|
|
|
|
private var playerImage: PlayerImageView = itemView.findViewById(R.id.player_image_rha) |
|
|
|
|
private var actionButton: AppCompatButton = itemView.findViewById(R.id.actionButton) |
|
|
|
|
@ -503,18 +508,19 @@ class EditorAdapter( |
|
|
|
|
amountEditText.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL |
|
|
|
|
amountEditText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
amountEditText.setOnTouchListener { _, event -> |
|
|
|
|
amountEditText.setOnTouchListener { view, event -> |
|
|
|
|
|
|
|
|
|
// Timber.d("=== event.action = ${event.action}") |
|
|
|
|
if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
|
amountEditText.isFocusable = true |
|
|
|
|
amountEditText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
amountEditText.requestFocus() |
|
|
|
|
// amountEditText.isFocusable = true |
|
|
|
|
// amountEditText.isFocusableInTouchMode = true |
|
|
|
|
// |
|
|
|
|
// amountEditText.requestFocus() |
|
|
|
|
|
|
|
|
|
editTextSelected(amountEditText) |
|
|
|
|
} |
|
|
|
|
view.performClick() |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -568,7 +574,7 @@ class EditorAdapter( |
|
|
|
|
/** |
|
|
|
|
* Display a hand street |
|
|
|
|
*/ |
|
|
|
|
inner class RowStreetHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
inner class RowStreetHolder(itemView: View) : AbstractRowHandHolder(itemView) { |
|
|
|
|
private var cardsLayout: LinearLayout = itemView.findViewById(R.id.cardsLayout) |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
@ -586,7 +592,7 @@ class EditorAdapter( |
|
|
|
|
/** |
|
|
|
|
* Display a hand action |
|
|
|
|
*/ |
|
|
|
|
inner class RowPlayerSummaryHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
inner class RowPlayerSummaryHolder(itemView: View) : AbstractRowHandHolder(itemView) { |
|
|
|
|
private var hpsPlayerImage: PlayerImageView = itemView.findViewById(R.id.hps_player_image) |
|
|
|
|
private var handLayout: LinearLayout = itemView.findViewById(R.id.handLayout) |
|
|
|
|
|
|
|
|
|
@ -613,7 +619,7 @@ class EditorAdapter( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
abstract inner class AbstractRowPlayerSetup(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
abstract inner class AbstractRowPlayerSetup(itemView: View) : AbstractRowHandHolder(itemView) { |
|
|
|
|
private var psHandLayout: LinearLayout = itemView.findViewById(R.id.ps_hand_layout) |
|
|
|
|
private var positionButton: AppCompatButton = itemView.findViewById(R.id.position_button) |
|
|
|
|
|
|
|
|
|
|