|
|
|
|
@ -8,7 +8,7 @@ import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import android.widget.Button |
|
|
|
|
import android.widget.EditText |
|
|
|
|
import androidx.core.view.isVisible |
|
|
|
|
import android.widget.LinearLayout |
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
import com.google.android.material.chip.Chip |
|
|
|
|
@ -21,7 +21,7 @@ import kotlinx.android.synthetic.main.row_hhsettings_straddle.view.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Card |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.BindableHolder |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RecyclerAdapter |
|
|
|
|
@ -282,6 +282,26 @@ class HandHistoryAdapter( |
|
|
|
|
return itemView.findViewWithTag(tag) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun configureCardsLayout(layout: LinearLayout) { |
|
|
|
|
layout.removeAllViews() |
|
|
|
|
|
|
|
|
|
val inflater = LayoutInflater.from(itemView.context) |
|
|
|
|
|
|
|
|
|
dataSource.rowRepresentableForPosition(this.currentPosition)?.let { row -> |
|
|
|
|
|
|
|
|
|
dataSource.contentForRow(row, itemView.context, Card::class).forEach { card -> |
|
|
|
|
val cardView = card.view(itemView.context, inflater, layout) |
|
|
|
|
layout.addView(cardView) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
layout.setOnClickListener { |
|
|
|
|
delegate?.onRowSelected(this.currentPosition, row) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class RowHandBlinds(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
@ -424,31 +444,24 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
|
|
|
|
|
itemView.flopEditText.tag = Street.FLOP.ordinal |
|
|
|
|
itemView.turnEditText.tag = Street.TURN.ordinal |
|
|
|
|
itemView.riverEditText.tag = Street.RIVER.ordinal |
|
|
|
|
|
|
|
|
|
setClickListener(itemView.flopEditText) |
|
|
|
|
setClickListener(itemView.turnEditText) |
|
|
|
|
setClickListener(itemView.riverEditText) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
super.onBind(position, row, adapter) |
|
|
|
|
|
|
|
|
|
val streetCardsRow = row as StreetCardsRow |
|
|
|
|
val street = streetCardsRow.street |
|
|
|
|
configureCardsLayout(itemView.cardsLayout) |
|
|
|
|
|
|
|
|
|
configureEditTexts(Street.FLOP.ordinal..Street.RIVER.ordinal, position, row, adapter) |
|
|
|
|
|
|
|
|
|
itemView.flopEditText.isEnabled = (street == Street.FLOP || street == Street.SUMMARY) |
|
|
|
|
itemView.turnEditText.isEnabled = (street == Street.TURN || street == Street.SUMMARY) |
|
|
|
|
itemView.riverEditText.isEnabled = (street == Street.RIVER || street == Street.SUMMARY) |
|
|
|
|
|
|
|
|
|
itemView.flopEditText.isVisible = (street.ordinal >= Street.FLOP.ordinal) |
|
|
|
|
itemView.turnEditText.isVisible = (street.ordinal >= Street.TURN.ordinal) |
|
|
|
|
itemView.riverEditText.isVisible = (street.ordinal >= Street.RIVER.ordinal) |
|
|
|
|
// itemView.cardsLayout.removeAllViews() |
|
|
|
|
// |
|
|
|
|
// val inflater = LayoutInflater.from(itemView.context) |
|
|
|
|
// adapter.dataSource.contentForRow(row, itemView.context, Card::class).forEach { card -> |
|
|
|
|
// val cardView = card.view(itemView.context, inflater, itemView.cardsLayout) |
|
|
|
|
// itemView.cardsLayout.addView(cardView) |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// itemView.cardsLayout.setOnClickListener { |
|
|
|
|
// adapter.delegate?.onRowSelected(position, row) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -460,27 +473,27 @@ class HandHistoryAdapter( |
|
|
|
|
inner class RowHandPlayerSummary(itemView: View) : RowHandHolder(itemView) { |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
itemView.cardsEditText.tag = PlayerCardsRow.Tag.CARDS.ordinal |
|
|
|
|
// itemView.cardsEditText.tag = PlayerCardsRow.Tag.CARDS.ordinal |
|
|
|
|
|
|
|
|
|
// Cards |
|
|
|
|
itemView.findViewById<EditText>(R.id.cardsEditText)?.let { cardsEditText -> |
|
|
|
|
|
|
|
|
|
cardsEditText.isFocusableInTouchMode = true |
|
|
|
|
cardsEditText.setOnTouchListener { _, event -> |
|
|
|
|
|
|
|
|
|
if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
|
cardsEditText.isFocusable = true |
|
|
|
|
cardsEditText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
cardsEditText.requestFocus() |
|
|
|
|
|
|
|
|
|
editTextSelected(cardsEditText, true, PlayerCardsRow.Tag.CARDS.ordinal) |
|
|
|
|
} |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// itemView.findViewById<EditText>(R.id.cardsEditText)?.let { cardsEditText -> |
|
|
|
|
// |
|
|
|
|
// cardsEditText.isFocusableInTouchMode = true |
|
|
|
|
// cardsEditText.setOnTouchListener { _, event -> |
|
|
|
|
// |
|
|
|
|
// if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
|
// // Both are required, otherwise requestFocus() fails |
|
|
|
|
// cardsEditText.isFocusable = true |
|
|
|
|
// cardsEditText.isFocusableInTouchMode = true |
|
|
|
|
// |
|
|
|
|
// cardsEditText.requestFocus() |
|
|
|
|
// |
|
|
|
|
// editTextSelected(cardsEditText, true, PlayerCardsRow.Tag.CARDS.ordinal) |
|
|
|
|
// } |
|
|
|
|
// return@setOnTouchListener true |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
@ -494,7 +507,9 @@ class HandHistoryAdapter( |
|
|
|
|
positionButton.text = playerCardView.position?.value ?: throw PAIllegalStateException("Should not happen") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
configureEditTexts(PlayerCardsRow.Tag.CARDS.ordinal, position, row, adapter) |
|
|
|
|
configureCardsLayout(itemView.handLayout) |
|
|
|
|
|
|
|
|
|
// configureEditTexts(PlayerCardsRow.Tag.CARDS.ordinal, position, row, adapter) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -506,10 +521,7 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
|
|
|
|
|
itemView.handEditText.tag = PlayerSetupRow.Tag.HAND.ordinal |
|
|
|
|
itemView.stackEditText.tag = PlayerSetupRow.Tag.STACK.ordinal |
|
|
|
|
|
|
|
|
|
setClickListener(itemView.handEditText) |
|
|
|
|
setClickListener(itemView.stackEditText) |
|
|
|
|
|
|
|
|
|
// Position Recycler |
|
|
|
|
@ -578,7 +590,9 @@ class HandHistoryAdapter( |
|
|
|
|
// Settings |
|
|
|
|
itemView.settings_container.visibility = if (state == PlayerSetupRow.State.POSITIONS_ONLY) View.GONE else View.VISIBLE |
|
|
|
|
|
|
|
|
|
configureEditTexts(PlayerSetupRow.Tag.HAND.ordinal, position, row, adapter) |
|
|
|
|
|
|
|
|
|
configureCardsLayout(itemView.psHandLayout) |
|
|
|
|
// configureEditTexts(PlayerSetupRow.Tag.HAND.ordinal, position, row, adapter) |
|
|
|
|
configureEditTexts(PlayerSetupRow.Tag.STACK.ordinal, position, row, adapter) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|