Fixes bugs + improvements

hh
Laurent 6 years ago
parent 3acb0f02ef
commit e29e60576a
  1. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt
  2. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  3. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  4. 3
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionReadRow.kt
  5. 8
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt
  6. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/PlayerImageView.kt
  7. 7
      app/src/main/res/layout/row_hand_action_read.xml

@ -29,7 +29,7 @@ fun List<Action>.compact(positions: LinkedHashSet<Position>): List<ActionReadRow
fun Action.toReadRow(positions: LinkedHashSet<Position>): ActionReadRow { fun Action.toReadRow(positions: LinkedHashSet<Position>): ActionReadRow {
val pos = positions.elementAt(this.position) val pos = positions.elementAt(this.position)
return ActionReadRow(mutableListOf(pos), this.type, this.amount) return ActionReadRow(mutableListOf(pos), this.position, this.type, this.amount)
} }
open class Action : RealmObject() { open class Action : RealmObject() {

@ -161,13 +161,13 @@ class HandHistoryAdapter(
return itemView.context.getColor(color) return itemView.context.getColor(color)
} }
fun editTextSelected(editText: EditText, selected: Boolean, tag: Int) { fun editTextSelected(editText: EditText, selected: Boolean) {
editText.setBackgroundColor(color(selected)) editText.setBackgroundColor(color(selected))
val row = dataSource.rowRepresentableForPosition(this.currentPosition) val row = dataSource.rowRepresentableForPosition(this.currentPosition)
?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition") ?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition")
delegate?.onRowSelected(this.currentPosition, row, tag) delegate?.onRowSelected(this.currentPosition, row, editText.tag as Int)
} }
@ -231,7 +231,7 @@ class HandHistoryAdapter(
editText.requestFocus() editText.requestFocus()
editTextSelected(editText, true, editText.tag as Int) editTextSelected(editText, true)
} }
return@setOnTouchListener true return@setOnTouchListener true
} }
@ -295,7 +295,6 @@ class HandHistoryAdapter(
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)
// layout.setBackgroundColor(color(focused))
val drawableId = if (focused) R.drawable.rounded_highlighted_board_background else R.drawable.rounded_board_background val drawableId = if (focused) R.drawable.rounded_highlighted_board_background else R.drawable.rounded_board_background
layout.background = itemView.resources.getDrawable(drawableId, null) layout.background = itemView.resources.getDrawable(drawableId, null)
@ -394,7 +393,7 @@ class HandHistoryAdapter(
amountEditText.requestFocus() amountEditText.requestFocus()
editTextSelected(amountEditText, true, HHKeyboard.AMOUNT.ordinal) editTextSelected(amountEditText, true)
} }
return@setOnTouchListener true return@setOnTouchListener true
} }
@ -472,7 +471,7 @@ class HandHistoryAdapter(
// Position // Position
itemView.findViewById<Button>(R.id.positionButton)?.let { positionButton -> itemView.findViewById<Button>(R.id.positionButton)?.let { positionButton ->
positionButton.text = playerCardView.position?.value ?: throw PAIllegalStateException("Should not happen") positionButton.text = playerCardView.position.value
} }
configureCardsLayout(itemView.handLayout) configureCardsLayout(itemView.handLayout)

@ -271,9 +271,9 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
this.save() this.save()
} }
if (this.model.isEdited) { // if (this.model.isEdited && this.model.isNew) {
this.findNextActionToEdit(0) // this.findNextActionToEdit(0)
} // }
this.handHistoryAdapter.notifyDataSetChanged() this.handHistoryAdapter.notifyDataSetChanged()
} }

@ -6,8 +6,9 @@ import net.pokeranalytics.android.ui.modules.handhistory.HandRowType
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
class ActionReadRow(var positions: MutableList<Position>, class ActionReadRow(var positions: MutableList<Position>,
override var positionIndex: Int,
var action: Action.Type?, var action: Action.Type?,
var amount: Double?) : RowRepresentable { var amount: Double?) : RowRepresentable, PositionalRow {
enum class Tag { enum class Tag {
PLAYER PLAYER

@ -220,9 +220,9 @@ class ComputedAction(var manager: ActionManager,
this.setEffectiveAmount(significantAmount - committedAmount) this.setEffectiveAmount(significantAmount - committedAmount)
} }
private fun getStreetSignificantActionBefore(index: Int): ComputedAction? { // private fun getStreetSignificantActionBefore(index: Int): ComputedAction? {
return this.manager.getStreetLastSignificantAction(this.street, index - 1) // return this.manager.getStreetLastSignificantAction(this.street, index - 1)
} // }
private fun getStreetLastSignificantAction(): ComputedAction? { private fun getStreetLastSignificantAction(): ComputedAction? {
return this.manager.getStreetLastSignificantAction(this.street, this.action.index - 1) return this.manager.getStreetLastSignificantAction(this.street, this.action.index - 1)
@ -277,7 +277,7 @@ class ComputedAction(var manager: ActionManager,
* The "read mode" representation of the action * The "read mode" representation of the action
*/ */
fun toReadRow(): ActionReadRow { fun toReadRow(): ActionReadRow {
return ActionReadRow(mutableListOf(this.position), this.action.type, this.action.amount) return ActionReadRow(mutableListOf(this.position), this.positionIndex, this.action.type, this.action.amount)
} }
override val positionIndex: Int override val positionIndex: Int

@ -148,6 +148,8 @@ class PlayerImageView : FrameLayout {
fun clear(size: Size = Size.NORMAL) { fun clear(size: Size = Size.NORMAL) {
val drawable = this.playerImageView.playerStroke.background as GradientDrawable? val drawable = this.playerImageView.playerStroke.background as GradientDrawable?
drawable?.setStroke(size.getStrokeSize(), getColor(context, R.color.kaki)) drawable?.setStroke(size.getStrokeSize(), getColor(context, R.color.kaki))
this.playerImageView.playerInitial.text = null
} }
} }

@ -16,9 +16,10 @@
android:id="@+id/playersText" android:id="@+id/playersText"
style="@style/PokerAnalyticsTheme.TextView.RowTitle" style="@style/PokerAnalyticsTheme.TextView.RowTitle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:gravity="center_vertical"
tools:text="BB" tools:text="BB"
/> />
@ -26,7 +27,7 @@
android:id="@+id/actionText" android:id="@+id/actionText"
style="@style/PokerAnalyticsTheme.TextView.RowTitle" style="@style/PokerAnalyticsTheme.TextView.RowTitle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
tools:text="raises"/> tools:text="raises"/>
@ -35,7 +36,7 @@
android:id="@+id/amountText" android:id="@+id/amountText"
style="@style/PokerAnalyticsTheme.TextView.RowTitle" style="@style/PokerAnalyticsTheme.TextView.RowTitle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"

Loading…
Cancel
Save