|
|
|
|
@ -3,24 +3,13 @@ package net.pokeranalytics.android.ui.modules.handhistory.editor |
|
|
|
|
import android.content.res.ColorStateList |
|
|
|
|
import android.text.InputType |
|
|
|
|
import android.view.* |
|
|
|
|
import android.widget.Button |
|
|
|
|
import android.widget.EditText |
|
|
|
|
import android.widget.LinearLayout |
|
|
|
|
import android.widget.TextView |
|
|
|
|
import android.widget.* |
|
|
|
|
import androidx.appcompat.widget.AppCompatButton |
|
|
|
|
import androidx.core.view.isEmpty |
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
import com.google.android.material.chip.Chip |
|
|
|
|
import kotlinx.android.synthetic.main.row_hand_action.view.* |
|
|
|
|
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.position_button |
|
|
|
|
import kotlinx.android.synthetic.main.row_hhsettings_player_setup.view.ps_hand_layout |
|
|
|
|
import kotlinx.android.synthetic.main.row_hhsettings_player_setup_read.view.* |
|
|
|
|
import kotlinx.android.synthetic.main.row_hhsettings_straddle.view.* |
|
|
|
|
import kotlinx.android.synthetic.main.row_recycler.view.* |
|
|
|
|
import com.google.android.material.internal.FlowLayout |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
|
@ -69,9 +58,9 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { |
|
|
|
|
override val bottomSheetType: BottomSheetType |
|
|
|
|
get() { |
|
|
|
|
return when(this) { |
|
|
|
|
PLAYER_NUMBER -> BottomSheetType.GRID |
|
|
|
|
COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES |
|
|
|
|
ANTE -> BottomSheetType.NUMERIC_TEXT |
|
|
|
|
PLAYER_NUMBER -> BottomSheetType.GRID |
|
|
|
|
COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES |
|
|
|
|
ANTE -> BottomSheetType.NUMERIC_TEXT |
|
|
|
|
else -> BottomSheetType.NONE |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -79,11 +68,11 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { |
|
|
|
|
override val resId: Int? |
|
|
|
|
get() { |
|
|
|
|
return when(this) { |
|
|
|
|
PLAYER_NUMBER -> R.string.number_of_players |
|
|
|
|
COMMENT -> R.string.comment |
|
|
|
|
ANTE -> R.string.ante |
|
|
|
|
BIG_BLIND_ANTE, BIG_BLIND_ANTE_READ -> R.string.bb_ante_option |
|
|
|
|
SETTINGS_HEADER -> R.string.settings |
|
|
|
|
PLAYER_NUMBER -> R.string.number_of_players |
|
|
|
|
COMMENT -> R.string.comment |
|
|
|
|
ANTE -> R.string.ante |
|
|
|
|
BIG_BLIND_ANTE, BIG_BLIND_ANTE_READ -> R.string.bb_ante_option |
|
|
|
|
SETTINGS_HEADER -> R.string.settings |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -91,8 +80,8 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { |
|
|
|
|
override val imageRes: Int? |
|
|
|
|
get() { |
|
|
|
|
return when(this) { |
|
|
|
|
COMMENT -> R.drawable.picto_comment |
|
|
|
|
SETTINGS_HEADER -> R.drawable.ic_settings |
|
|
|
|
COMMENT -> R.drawable.picto_comment |
|
|
|
|
SETTINGS_HEADER -> R.drawable.ic_settings |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -103,8 +92,9 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class EditorAdapter( |
|
|
|
|
override var dataSource: RowRepresentableDataSource, |
|
|
|
|
override var delegate: RowRepresentableDelegate? = null) : |
|
|
|
|
override var dataSource: RowRepresentableDataSource, |
|
|
|
|
override var delegate: RowRepresentableDelegate? = null |
|
|
|
|
) : |
|
|
|
|
RecyclerView.Adapter<RecyclerView.ViewHolder>(), |
|
|
|
|
RecyclerAdapter { |
|
|
|
|
|
|
|
|
|
@ -116,21 +106,21 @@ class EditorAdapter( |
|
|
|
|
val rowType: HandRowType = HandRowType.values()[viewType] |
|
|
|
|
val layout = LayoutInflater.from(parent.context).inflate(rowType.layoutRes, parent, false) |
|
|
|
|
return when (rowType) { |
|
|
|
|
HandRowType.DEFAULT -> RowViewHolder(layout) |
|
|
|
|
HandRowType.HEADER -> RowViewHolder(layout) |
|
|
|
|
HandRowType.SETTINGS_HEADER -> RowViewHolder(layout) |
|
|
|
|
HandRowType.ACTION -> RowActionHolder(layout) |
|
|
|
|
HandRowType.STREET -> RowStreetHolder(layout) |
|
|
|
|
HandRowType.PLAYER_SUMMARY -> RowPlayerSummaryHolder(layout) |
|
|
|
|
HandRowType.STRADDLE -> RowStraddleHolder(layout) |
|
|
|
|
HandRowType.PLAYER_SETUP -> RowPlayerSetupHolder(layout) |
|
|
|
|
HandRowType.PLAYER_SETUP_READ -> RowReadOnlyPlayerSetupHolder(layout) |
|
|
|
|
HandRowType.COMMENT -> RowViewHolder(layout) |
|
|
|
|
HandRowType.ACTION_READ -> RowActionReadHolder(layout) |
|
|
|
|
HandRowType.HERO_POSITION, HandRowType.PLAYER_POSITION -> RowPositionHolder(layout) |
|
|
|
|
HandRowType.PLAYER_NUMBER, |
|
|
|
|
HandRowType.ANTE, |
|
|
|
|
HandRowType.BIG_BLIND_ANTE, HandRowType.BIG_BLIND_ANTE_READ -> RowViewHolder(layout) |
|
|
|
|
HandRowType.DEFAULT -> RowViewHolder(layout) |
|
|
|
|
HandRowType.HEADER -> RowViewHolder(layout) |
|
|
|
|
HandRowType.SETTINGS_HEADER -> RowViewHolder(layout) |
|
|
|
|
HandRowType.ACTION -> RowActionHolder(layout) |
|
|
|
|
HandRowType.STREET -> RowStreetHolder(layout) |
|
|
|
|
HandRowType.PLAYER_SUMMARY -> RowPlayerSummaryHolder(layout) |
|
|
|
|
HandRowType.STRADDLE -> RowStraddleHolder(layout) |
|
|
|
|
HandRowType.PLAYER_SETUP -> RowPlayerSetupHolder(layout) |
|
|
|
|
HandRowType.PLAYER_SETUP_READ -> RowReadOnlyPlayerSetupHolder(layout) |
|
|
|
|
HandRowType.COMMENT -> RowViewHolder(layout) |
|
|
|
|
HandRowType.ACTION_READ -> RowActionReadHolder(layout) |
|
|
|
|
HandRowType.HERO_POSITION, HandRowType.PLAYER_POSITION -> RowPositionHolder(layout) |
|
|
|
|
HandRowType.PLAYER_NUMBER, |
|
|
|
|
HandRowType.ANTE, |
|
|
|
|
HandRowType.BIG_BLIND_ANTE, HandRowType.BIG_BLIND_ANTE_READ -> RowViewHolder(layout) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -180,15 +170,27 @@ class EditorAdapter( |
|
|
|
|
this.currentPosition = position |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun configureEditTexts(index: Int, position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
protected fun configureEditTexts( |
|
|
|
|
index: Int, |
|
|
|
|
position: Int, |
|
|
|
|
row: RowRepresentable, |
|
|
|
|
adapter: RecyclerAdapter |
|
|
|
|
) { |
|
|
|
|
this.configureEditTexts(index..index, position, row, adapter) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun configureEditTexts(tagRange: IntRange, position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
private fun configureEditTexts( |
|
|
|
|
tagRange: IntRange, |
|
|
|
|
position: Int, |
|
|
|
|
row: RowRepresentable, |
|
|
|
|
adapter: RecyclerAdapter |
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
tagRange.forEach { tag -> |
|
|
|
|
|
|
|
|
|
val editText = itemView.findViewWithTag<EditText>(tag) ?: throw PAIllegalStateException("Edit Text not found for tag: $tag, class: $this") |
|
|
|
|
val editText = itemView.findViewWithTag<EditText>(tag) ?: throw PAIllegalStateException( |
|
|
|
|
"Edit Text not found for tag: $tag, class: $this" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// hides soft input view |
|
|
|
|
editText.setTextIsSelectable(true) |
|
|
|
|
@ -229,7 +231,9 @@ class EditorAdapter( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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") |
|
|
|
|
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) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -287,7 +291,11 @@ class EditorAdapter( |
|
|
|
|
return itemView.findViewWithTag(tag) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun configurePlayerImage(playerImageView: PlayerImageView, position: Int, row: RowRepresentable) { |
|
|
|
|
protected fun configurePlayerImage( |
|
|
|
|
playerImageView: PlayerImageView, |
|
|
|
|
position: Int, |
|
|
|
|
row: RowRepresentable |
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
// Player |
|
|
|
|
val listener = View.OnClickListener { |
|
|
|
|
@ -359,6 +367,8 @@ class EditorAdapter( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowStraddleHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
private var container: ViewGroup = itemView.findViewById(R.id.container) |
|
|
|
|
private var positionsChipGroup: FlowLayout = itemView.findViewById(R.id.positionsChipGroup) |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
super.onBind(position, row, adapter) |
|
|
|
|
@ -366,10 +376,14 @@ class EditorAdapter( |
|
|
|
|
val straddleRow = row as StraddleRowRepresentable |
|
|
|
|
|
|
|
|
|
adapter.dataSource.backgroundColor(position, row)?.let { color -> |
|
|
|
|
itemView.findViewById<ViewGroup>(R.id.container)?.setBackgroundColor(itemView.context.getColor(color)) |
|
|
|
|
this.container.setBackgroundColor( |
|
|
|
|
itemView.context.getColor( |
|
|
|
|
color |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
itemView.positionsChipGroup.removeAllViews() |
|
|
|
|
this.positionsChipGroup.removeAllViews() |
|
|
|
|
straddleRow.positions.forEach { pos -> |
|
|
|
|
|
|
|
|
|
val chip = Chip(itemView.context) |
|
|
|
|
@ -388,20 +402,21 @@ class EditorAdapter( |
|
|
|
|
} |
|
|
|
|
adapter.delegate?.onRowValueChanged(straddleRow.selectedPositions, row) |
|
|
|
|
} |
|
|
|
|
itemView.positionsChipGroup.addView(chip) |
|
|
|
|
this.positionsChipGroup.addView(chip) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowPositionHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
private var recycler: RecyclerView = itemView.findViewById(R.id.recycler) |
|
|
|
|
|
|
|
|
|
private var positionAdapter: PositionAdapter = PositionAdapter() |
|
|
|
|
private var positionViewManager: LinearLayoutManager = |
|
|
|
|
LinearLayoutManager(itemView.context, RecyclerView.HORIZONTAL, false) |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.recycler.apply { |
|
|
|
|
this.recycler.apply { |
|
|
|
|
setHasFixedSize(true) |
|
|
|
|
layoutManager = positionViewManager |
|
|
|
|
adapter = positionAdapter |
|
|
|
|
@ -411,7 +426,11 @@ class EditorAdapter( |
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
super.onBind(position, row, adapter) |
|
|
|
|
|
|
|
|
|
this.positionAdapter.positions = adapter.dataSource.contentForRow(row, itemView.context, Position::class) |
|
|
|
|
this.positionAdapter.positions = adapter.dataSource.contentForRow( |
|
|
|
|
row, |
|
|
|
|
itemView.context, |
|
|
|
|
Position::class |
|
|
|
|
) |
|
|
|
|
this.positionAdapter.setOnClickListener { pos -> |
|
|
|
|
adapter.delegate?.onRowValueChanged(pos, row) |
|
|
|
|
this.positionAdapter.notifyDataSetChanged() |
|
|
|
|
@ -427,26 +446,33 @@ class EditorAdapter( |
|
|
|
|
|
|
|
|
|
inner class RowActionReadHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.player_image_rhar.tag = ActionReadRow.Tag.PLAYER.ordinal |
|
|
|
|
itemView.stackText.tag = ActionReadRow.Tag.STACK.ordinal |
|
|
|
|
private var playerImage: PlayerImageView = itemView.findViewById(R.id.player_image_rhar) |
|
|
|
|
private var stackText: TextView = itemView.findViewById(R.id.stackText) |
|
|
|
|
private var playersText: TextView = itemView.findViewById(R.id.playersText) |
|
|
|
|
private var actionText: TextView = itemView.findViewById(R.id.actionText) |
|
|
|
|
private var actionContainer: View = itemView.findViewById(R.id.action_container) |
|
|
|
|
private var amountText: TextView = itemView.findViewById(R.id.amountText) |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
playerImage.tag = ActionReadRow.Tag.PLAYER.ordinal |
|
|
|
|
stackText.tag = ActionReadRow.Tag.STACK.ordinal |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
|
|
|
|
|
configurePlayerImage(itemView.player_image_rhar, position, row) |
|
|
|
|
configurePlayerImage(this.playerImage, position, row) |
|
|
|
|
|
|
|
|
|
val actionReadRow = row as ActionReadRow |
|
|
|
|
itemView.playersText.text = actionReadRow.positions.joinToString(", ") { it.value } |
|
|
|
|
this.playersText.text = actionReadRow.positions.joinToString(", ") { it.value } |
|
|
|
|
|
|
|
|
|
actionReadRow.action?.let { type -> |
|
|
|
|
itemView.actionText.text = type.localizedTitle(itemView.context) |
|
|
|
|
this.actionText.text = type.localizedTitle(itemView.context) |
|
|
|
|
val background = itemView.context.getDrawable(type.background) |
|
|
|
|
itemView.action_container.background = background |
|
|
|
|
this.actionContainer.background = background |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
itemView.amountText.text = actionReadRow.amount?.formatted |
|
|
|
|
itemView.stackText.text = actionReadRow.stack?.formatted |
|
|
|
|
this.amountText.text = actionReadRow.amount?.formatted |
|
|
|
|
this.stackText.text = actionReadRow.stack?.formatted |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -456,36 +482,42 @@ class EditorAdapter( |
|
|
|
|
*/ |
|
|
|
|
inner class RowActionHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.player_image_rha.tag = ComputedAction.Tag.PLAYER.ordinal |
|
|
|
|
itemView.actionButton.tag = ComputedAction.Tag.ACTION.ordinal |
|
|
|
|
itemView.amountEditText.tag = ComputedAction.Tag.AMOUNT.ordinal |
|
|
|
|
private var playerImage: PlayerImageView = itemView.findViewById(R.id.player_image_rha) |
|
|
|
|
private var actionButton: AppCompatButton = itemView.findViewById(R.id.actionButton) |
|
|
|
|
private var amountEditText: EditText = itemView.findViewById(R.id.amountEditText) |
|
|
|
|
private var positionButton: AppCompatButton = itemView.findViewById(R.id.positionButton) |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
|
|
|
|
|
this.playerImage.tag = ComputedAction.Tag.PLAYER.ordinal |
|
|
|
|
this.actionButton.tag = ComputedAction.Tag.ACTION.ordinal |
|
|
|
|
this.amountEditText.tag = ComputedAction.Tag.AMOUNT.ordinal |
|
|
|
|
|
|
|
|
|
// Action |
|
|
|
|
setOnClickListener(itemView.actionButton) |
|
|
|
|
setOnClickListener(this.actionButton) |
|
|
|
|
|
|
|
|
|
// Amount |
|
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
|
this.amountEditText.let { amountEditText -> |
|
|
|
|
|
|
|
|
|
amountEditText.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL |
|
|
|
|
amountEditText.isFocusableInTouchMode = true |
|
|
|
|
amountEditText.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL |
|
|
|
|
amountEditText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
amountEditText.setOnTouchListener { _, event -> |
|
|
|
|
amountEditText.setOnTouchListener { _, 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 |
|
|
|
|
// 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.requestFocus() |
|
|
|
|
|
|
|
|
|
editTextSelected(amountEditText) |
|
|
|
|
} |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
editTextSelected(amountEditText) |
|
|
|
|
} |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun positionColor(isFocused: Boolean) : Int { |
|
|
|
|
@ -498,17 +530,17 @@ class EditorAdapter( |
|
|
|
|
|
|
|
|
|
val computedAction = row as ComputedAction |
|
|
|
|
|
|
|
|
|
configurePlayerImage(itemView.player_image_rha, position, row) |
|
|
|
|
configurePlayerImage(this.playerImage, position, row) |
|
|
|
|
|
|
|
|
|
// Position |
|
|
|
|
itemView.findViewById<Button>(R.id.positionButton)?.let { button -> |
|
|
|
|
this.positionButton.let { button -> |
|
|
|
|
button.text = computedAction.position.value |
|
|
|
|
// button.setBackgroundColor(color(computedAction.isHero)) |
|
|
|
|
button.backgroundTintList = ColorStateList.valueOf(positionColor(computedAction.isHero)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Action |
|
|
|
|
itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton -> |
|
|
|
|
this.actionButton.let { actionButton -> |
|
|
|
|
actionButton.isEnabled = adapter.dataSource.isEnabled(row, actionButton.tag as Int) |
|
|
|
|
|
|
|
|
|
val selected = adapter.dataSource.isSelected(position, row, actionButton.tag as Int) |
|
|
|
|
@ -523,7 +555,7 @@ class EditorAdapter( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Amount |
|
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
|
this.amountEditText.let { amountEditText -> |
|
|
|
|
val tag = amountEditText.tag as Int |
|
|
|
|
configureEditTexts(tag, position, row, adapter) |
|
|
|
|
} |
|
|
|
|
@ -536,14 +568,15 @@ class EditorAdapter( |
|
|
|
|
* Display a hand street |
|
|
|
|
*/ |
|
|
|
|
inner class RowStreetHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
private var cardsLayout: LinearLayout = itemView.findViewById(R.id.cardsLayout) |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
super.onBind(position, row, adapter) |
|
|
|
|
|
|
|
|
|
val streetCardsRow = row as StreetCardsRow |
|
|
|
|
itemView.cardsLayout.tag = streetCardsRow.street.ordinal |
|
|
|
|
this.cardsLayout.tag = streetCardsRow.street.ordinal |
|
|
|
|
|
|
|
|
|
configureCardsLayout(itemView.cardsLayout, true) |
|
|
|
|
configureCardsLayout(this.cardsLayout, true) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -553,10 +586,12 @@ class EditorAdapter( |
|
|
|
|
* Display a hand action |
|
|
|
|
*/ |
|
|
|
|
inner class RowPlayerSummaryHolder(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
private var hpsPlayerImage: PlayerImageView = itemView.findViewById(R.id.hps_player_image) |
|
|
|
|
private var handLayout: LinearLayout = itemView.findViewById(R.id.handLayout) |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.hps_player_image.tag = PlayerCardsRow.Tag.PLAYER.ordinal |
|
|
|
|
itemView.handLayout.tag = PlayerCardsRow.Tag.CARDS.ordinal |
|
|
|
|
this.hpsPlayerImage.tag = PlayerCardsRow.Tag.PLAYER.ordinal |
|
|
|
|
this.handLayout.tag = PlayerCardsRow.Tag.CARDS.ordinal |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
@ -571,18 +606,20 @@ class EditorAdapter( |
|
|
|
|
positionButton.setBackgroundColor(color(playerCardView.isHero)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
configurePlayerImage(itemView.hps_player_image, position, row) |
|
|
|
|
configurePlayerImage(this.hpsPlayerImage, position, row) |
|
|
|
|
|
|
|
|
|
configureCardsLayout(itemView.handLayout as LinearLayout, false) |
|
|
|
|
configureCardsLayout(this.handLayout, false) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
abstract inner class AbstractRowPlayerSetup(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
private var psHandLayout: LinearLayout = itemView.findViewById(R.id.ps_hand_layout) |
|
|
|
|
private var positionButton: AppCompatButton = itemView.findViewById(R.id.position_button) |
|
|
|
|
|
|
|
|
|
protected var delegate: RowRepresentableDelegate? = null |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.ps_hand_layout.tag = PlayerSetupRow.Tag.HAND.ordinal |
|
|
|
|
this.psHandLayout.tag = PlayerSetupRow.Tag.HAND.ordinal |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
@ -591,22 +628,28 @@ class EditorAdapter( |
|
|
|
|
this.delegate = adapter.delegate |
|
|
|
|
|
|
|
|
|
// Position Button |
|
|
|
|
itemView.position_button.text = adapter.dataSource.charSequenceForRow(row, itemView.context, PlayerSetupRow.Tag.POSITION.ordinal) |
|
|
|
|
this.positionButton.text = adapter.dataSource.charSequenceForRow( |
|
|
|
|
row, |
|
|
|
|
itemView.context, |
|
|
|
|
PlayerSetupRow.Tag.POSITION.ordinal |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
val positionalRow = row as PositionalRow |
|
|
|
|
itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionalRow.isHero)) |
|
|
|
|
this.positionButton.backgroundTintList = ColorStateList.valueOf(color(positionalRow.isHero)) |
|
|
|
|
|
|
|
|
|
configureCardsLayout(itemView.ps_hand_layout as LinearLayout, false) |
|
|
|
|
configureCardsLayout(this.psHandLayout, false) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowReadOnlyPlayerSetupHolder(itemView: View) : AbstractRowPlayerSetup(itemView) { |
|
|
|
|
private var psPlayerImage: PlayerImageView = itemView.findViewById(R.id.ps_player_image) |
|
|
|
|
private var stackTextView: TextView = itemView.findViewById(R.id.stack_text_view) |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.ps_player_image.tag = PlayerSetupRow.Tag.PLAYER.ordinal |
|
|
|
|
itemView.stack_text_view.tag = PlayerSetupRow.Tag.STACK.ordinal |
|
|
|
|
this.psPlayerImage.tag = PlayerSetupRow.Tag.PLAYER.ordinal |
|
|
|
|
this.stackTextView.tag = PlayerSetupRow.Tag.STACK.ordinal |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
@ -615,23 +658,27 @@ class EditorAdapter( |
|
|
|
|
configureTextView(PlayerSetupRow.Tag.STACK.ordinal, row, adapter) |
|
|
|
|
|
|
|
|
|
// Player |
|
|
|
|
configurePlayerImage(itemView.ps_player_image, position, row as PlayerSetupRow) |
|
|
|
|
configurePlayerImage(this.psPlayerImage, position, row as PlayerSetupRow) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowPlayerSetupHolder(itemView: View) : AbstractRowPlayerSetup(itemView) { |
|
|
|
|
private var playerImage: PlayerImageView = itemView.findViewById(R.id.player_image) |
|
|
|
|
private var positionButton: AppCompatButton = itemView.findViewById(R.id.position_button) |
|
|
|
|
private var psHandLayout: LinearLayout = itemView.findViewById(R.id.ps_hand_layout) |
|
|
|
|
private var stackEditText: EditText = itemView.findViewById(R.id.stack_edit_text) |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
|
|
|
|
|
itemView.player_image.tag = PlayerSetupRow.Tag.PLAYER.ordinal |
|
|
|
|
itemView.position_button.tag = PlayerSetupRow.Tag.POSITION.ordinal |
|
|
|
|
itemView.ps_hand_layout.tag = PlayerSetupRow.Tag.HAND.ordinal |
|
|
|
|
itemView.stack_edit_text.tag = PlayerSetupRow.Tag.STACK.ordinal |
|
|
|
|
this.playerImage.tag = PlayerSetupRow.Tag.PLAYER.ordinal |
|
|
|
|
this.positionButton.tag = PlayerSetupRow.Tag.POSITION.ordinal |
|
|
|
|
this.psHandLayout.tag = PlayerSetupRow.Tag.HAND.ordinal |
|
|
|
|
this.stackEditText.tag = PlayerSetupRow.Tag.STACK.ordinal |
|
|
|
|
|
|
|
|
|
itemView.stack_edit_text.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL |
|
|
|
|
setClickListener(itemView.stack_edit_text) |
|
|
|
|
setOnItemClickListener(itemView.position_button, false) |
|
|
|
|
this.stackEditText.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL |
|
|
|
|
setClickListener(this.stackEditText) |
|
|
|
|
setOnItemClickListener(this.positionButton, false) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -639,7 +686,7 @@ class EditorAdapter( |
|
|
|
|
super.onBind(position, row, adapter) |
|
|
|
|
|
|
|
|
|
// Player |
|
|
|
|
configurePlayerImage(itemView.player_image, position, row) |
|
|
|
|
configurePlayerImage(this.playerImage, position, row) |
|
|
|
|
configureEditTexts(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|