Crash fix + card layout in edit mode

hh
Laurent 6 years ago
parent 1338e21da1
commit 4ca7e1c201
  1. 12
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  2. 3
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt
  3. 7
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/StreetCardsRow.kt
  4. 4
      app/src/main/res/drawable/transparent.xml
  5. 26
      app/src/main/res/layout/row_hand_player_summary.xml
  6. 21
      app/src/main/res/layout/row_hhsettings_player_setup.xml
  7. 23
      app/src/main/res/layout/row_hhsettings_player_setup_read.xml
  8. 17
      app/src/main/res/layout/view_card_layout.xml

@ -288,11 +288,18 @@ class HandHistoryAdapter(
val inflater = LayoutInflater.from(itemView.context) val inflater = LayoutInflater.from(itemView.context)
val isEdited = (dataSource as HandHistoryViewModel).isEdited
dataSource.rowRepresentableForPosition(this.currentPosition)?.let { row -> dataSource.rowRepresentableForPosition(this.currentPosition)?.let { row ->
val focused = dataSource.isSelected(this.currentPosition, row, layout.tag as Int) val focused = dataSource.isSelected(this.currentPosition, row, layout.tag as Int)
val drawableId = if (focused) R.drawable.rounded_highlighted_board_background else R.drawable.rounded_board_background val drawableId = when {
focused -> R.drawable.rounded_highlighted_board_background
isBoard || isEdited -> R.drawable.rounded_board_background
else -> R.drawable.transparent
}
layout.background = itemView.resources.getDrawable(drawableId, null) layout.background = itemView.resources.getDrawable(drawableId, null)
dataSource.contentForRow(row, itemView.context, Card::class).forEach { card -> dataSource.contentForRow(row, itemView.context, Card::class).forEach { card ->
@ -489,6 +496,7 @@ class HandHistoryAdapter(
itemView.cardsLayout.tag = streetCardsRow.street.ordinal itemView.cardsLayout.tag = streetCardsRow.street.ordinal
configureCardsLayout(itemView.cardsLayout, true) configureCardsLayout(itemView.cardsLayout, true)
} }
} }
@ -536,7 +544,7 @@ class HandHistoryAdapter(
// Position Button // Position Button
itemView.position_button.text = adapter.dataSource.charSequenceForRow(row, itemView.context, PlayerSetupRow.Tag.POSITION.ordinal) itemView.position_button.text = adapter.dataSource.charSequenceForRow(row, itemView.context, PlayerSetupRow.Tag.POSITION.ordinal)
val positionSelected = adapter.dataSource.isSelected(position, row, PlayerSetupRow.Tag.POSITION.ordinal) // val positionSelected = adapter.dataSource.isSelected(position, row, PlayerSetupRow.Tag.POSITION.ordinal)
// itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionSelected)) // itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionSelected))
val positionalRow = row as PositionalRow val positionalRow = row as PositionalRow

@ -232,8 +232,7 @@ class ComputedAction(var manager: ActionManager,
val significantAction = getStreetLastSignificantAction() val significantAction = getStreetLastSignificantAction()
?: throw PAIllegalStateException("There must be a previously set significant action for a call to be set") ?: throw PAIllegalStateException("There must be a previously set significant action for a call to be set")
val significantAmount = significantAction.action.amount val significantAmount = significantAction.action.amount ?: 0.0
?: throw PAIllegalStateException("There must be a set amount on the action for the call to be set")
val committedAmount = getPreviouslyCommittedAmount() val committedAmount = getPreviouslyCommittedAmount()
this.setEffectiveAmount(significantAmount - committedAmount) this.setEffectiveAmount(significantAmount - committedAmount)

@ -43,13 +43,6 @@ class StreetCardsRow(var street: Street, var handHistory: HandHistory) : CardsRo
} }
} }
override fun clear() {
when (this.street) {
Street.SUMMARY -> this.cardHolder?.cards?.clear()
else -> this.handHistory.cards.removeAll { it.street == this.street }
}
}
override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean { override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean {
val street = Street.values()[tag] val street = Street.values()[tag]
return this.cardCount < street.totalBoardCards || this.handHistory.cards.elementAtOrNull(street.totalBoardCards - 1)?.suit == null return this.cardCount < street.totalBoardCards || this.handHistory.cards.elementAtOrNull(street.totalBoardCards - 1)?.suit == null

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/transparent"/>
</shape>

@ -20,17 +20,23 @@
android:layout_height="44dp" android:layout_height="44dp"
android:layout_marginStart="8dp"/> android:layout_marginStart="8dp"/>
<LinearLayout <include layout="@layout/view_card_layout"
android:id="@+id/handLayout" android:id="@+id/hand_layout"
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/rounded_board_background" android:layout_height="50dp"
android:layout_marginStart="8dp" android:layout_width="0dp" />
android:layout_marginEnd="8dp"
android:paddingStart="4dp" <!-- <LinearLayout-->
android:paddingEnd="0dp" /> <!-- android:id="@+id/handLayout"-->
<!-- android:orientation="horizontal"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="50dp"-->
<!-- android:layout_weight="1"-->
<!-- android:background="@drawable/rounded_board_background"-->
<!-- android:layout_marginStart="8dp"-->
<!-- android:layout_marginEnd="8dp"-->
<!-- android:paddingStart="4dp"-->
<!-- android:paddingEnd="0dp" />-->
<!-- <androidx.appcompat.widget.AppCompatEditText--> <!-- <androidx.appcompat.widget.AppCompatEditText-->
<!-- android:id="@+id/cardsEditText"--> <!-- android:id="@+id/cardsEditText"-->

@ -20,16 +20,21 @@
android:layout_height="44dp" android:layout_height="44dp"
android:layout_marginStart="8dp" /> android:layout_marginStart="8dp" />
<LinearLayout <include layout="@layout/view_card_layout"
android:id="@+id/ps_hand_layout" android:id="@+id/ps_hand_layout"
android:layout_width="144dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_marginStart="8dp" android:layout_width="144dp" />
android:background="@drawable/rounded_board_background"
android:gravity="center" <!-- <LinearLayout-->
android:orientation="horizontal" <!-- android:id="@+id/ps_hand_layout"-->
android:paddingStart="4dp" <!-- android:layout_width="144dp"-->
android:paddingEnd="0dp" /> <!-- android:layout_height="50dp"-->
<!-- android:layout_marginStart="8dp"-->
<!-- android:background="@drawable/rounded_board_background"-->
<!-- android:gravity="center"-->
<!-- android:orientation="horizontal"-->
<!-- android:paddingStart="4dp"-->
<!-- android:paddingEnd="0dp" />-->
<androidx.appcompat.widget.AppCompatEditText <androidx.appcompat.widget.AppCompatEditText
android:id="@+id/stack_edit_text" android:id="@+id/stack_edit_text"

@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:orientation="horizontal"> android:orientation="horizontal">
<net.pokeranalytics.android.ui.view.PlayerImageView <net.pokeranalytics.android.ui.view.PlayerImageView
@ -19,16 +21,21 @@
android:layout_height="44dp" android:layout_height="44dp"
android:layout_marginStart="8dp" /> android:layout_marginStart="8dp" />
<LinearLayout <include layout="@layout/view_card_layout"
android:id="@+id/ps_hand_layout" android:id="@+id/ps_hand_layout"
android:layout_width="144dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_marginStart="8dp" android:layout_width="144dp" />
android:background="@drawable/rounded_board_background"
android:gravity="center" <!-- <LinearLayout-->
android:orientation="horizontal" <!-- android:id="@+id/ps_hand_layout"-->
android:paddingStart="4dp" <!-- android:layout_width="144dp"-->
android:paddingEnd="0dp" /> <!-- android:layout_height="50dp"-->
<!-- android:layout_marginStart="8dp"-->
<!-- android:background="@drawable/rounded_board_background"-->
<!-- android:gravity="center"-->
<!-- android:orientation="horizontal"-->
<!-- android:paddingStart="4dp"-->
<!-- android:paddingEnd="0dp" />-->
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/stack_text_view" android:id="@+id/stack_text_view"

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="144dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:background="@drawable/rounded_board_background"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="4dp"
android:paddingEnd="0dp" />
<!--<androidx.constraintlayout.widget.ConstraintLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent">-->
<!--</androidx.constraintlayout.widget.ConstraintLayout>-->
Loading…
Cancel
Save