diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt index 2064a69a..a4cdcf13 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Card.kt @@ -15,6 +15,7 @@ import net.pokeranalytics.android.exceptions.PAIllegalStateException import net.pokeranalytics.android.model.handhistory.Street import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowViewType +import timber.log.Timber interface CardProperty @@ -99,7 +100,7 @@ open class Card : RealmObject() { } fun format(suit: Suit?) : String { - return suit?.value ?: "" + return suit?.value ?: UNDEFINED.value } fun color(suit: Suit?) : Int { return suit?.color ?: R.color.white @@ -191,6 +192,7 @@ open class Card : RealmObject() { spannable.length, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE ) + Timber.d("card format = $spannable") return spannable } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt index 39c60935..412e3e53 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt @@ -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(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(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) } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt index 80821af0..90afd482 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt @@ -679,6 +679,22 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra Position::class -> { return this.handHistory.undefinedPositions() as List } + Card::class -> { + + val cards = when (row) { + is StreetCardsRow -> { + this.handHistory.cardsForStreet(row.street) + } + is PlayerCardsRow -> { + row.cardHolder?.cards + } + is PlayerSetupRow -> { + row.cardHolder?.cards + } + else -> { throw PAIllegalStateException("unmanaged contentForRow for Card") } + } + return (cards ?: listOf()) as List + } } return listOf() } diff --git a/app/src/main/res/drawable/rounded_board_background.xml b/app/src/main/res/drawable/rounded_board_background.xml new file mode 100644 index 00000000..7bc43fd2 --- /dev/null +++ b/app/src/main/res/drawable/rounded_board_background.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_background.xml b/app/src/main/res/drawable/rounded_card_background.xml similarity index 100% rename from app/src/main/res/drawable/rounded_background.xml rename to app/src/main/res/drawable/rounded_card_background.xml diff --git a/app/src/main/res/layout/row_hand_cards.xml b/app/src/main/res/layout/row_hand_cards.xml index bf801bdf..ca9234cb 100644 --- a/app/src/main/res/layout/row_hand_cards.xml +++ b/app/src/main/res/layout/row_hand_cards.xml @@ -1,34 +1,14 @@ - - - - - - - - + android:layout_width="wrap_content" + android:layout_height="50dp" + android:background="@drawable/rounded_board_background" + android:layout_marginStart="16dp" + android:paddingStart="4dp" + android:paddingEnd="0dp" + android:gravity="center_vertical" + android:id="@+id/cardsLayout"> diff --git a/app/src/main/res/layout/row_hand_history_view.xml b/app/src/main/res/layout/row_hand_history_view.xml index 6f0f99bb..1781f899 100644 --- a/app/src/main/res/layout/row_hand_history_view.xml +++ b/app/src/main/res/layout/row_hand_history_view.xml @@ -22,7 +22,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/app/src/main/res/layout/row_hand_player_summary.xml b/app/src/main/res/layout/row_hand_player_summary.xml index 16659f4a..840c0b68 100644 --- a/app/src/main/res/layout/row_hand_player_summary.xml +++ b/app/src/main/res/layout/row_hand_player_summary.xml @@ -18,15 +18,27 @@ android:layout_height="44dp" android:layout_marginStart="8dp"/> - + android:layout_height="50dp" + android:layout_weight="1" + android:background="@drawable/rounded_board_background" + android:layout_marginStart="16dp" + android:paddingStart="4dp" + android:paddingEnd="0dp" + android:gravity="center"/> + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/row_hhsettings_player_setup.xml b/app/src/main/res/layout/row_hhsettings_player_setup.xml index f7734390..0fc9c462 100644 --- a/app/src/main/res/layout/row_hhsettings_player_setup.xml +++ b/app/src/main/res/layout/row_hhsettings_player_setup.xml @@ -37,16 +37,28 @@ android:layout_height="44dp" android:layout_marginStart="8dp"/> - + android:background="@drawable/rounded_board_background" + android:layout_marginStart="16dp" + android:paddingStart="4dp" + android:paddingEnd="0dp" + android:gravity="center"/> + + + + + + + + + + +