HH progression

hh
Laurent 6 years ago
parent c0c28c628f
commit 1c9932cd32
  1. 2
      app/src/main/java/net/pokeranalytics/android/model/handhistory/ComputedAction.kt
  2. 2
      app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt
  3. 29
      app/src/main/java/net/pokeranalytics/android/ui/fragment/HandHistoryFragment.kt
  4. 23
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt
  5. 3
      app/src/main/java/net/pokeranalytics/android/ui/view/handhistory/KeyboardContainer.kt
  6. 6
      app/src/main/java/net/pokeranalytics/android/ui/viewmodel/HandHistoryViewModel.kt
  7. 1
      app/src/main/res/layout/row_hand_action.xml
  8. 2
      app/src/main/res/values/strings.xml

@ -45,7 +45,7 @@ class ComputedAction(var action: Action,
override val viewType: Int = RowViewType.ROW_HAND_ACTION.ordinal
override fun keyboardForCompletion() : HHKeyboard? {
Timber.d("type = ${this.action.type} / amount = ${this.action.amount}")
Timber.d("index = ${action.index} / type = ${this.action.type} / amount = ${this.action.amount}")
return if (this.action.type != null) {
if (this.requiresAmount) {
HHKeyboard.AMOUNT

@ -326,7 +326,7 @@ class HHBuilder {
this.currentRowRepresentables.forEachIndexed { index, rowRepresentable ->
if (index >= startIndex && rowRepresentable is HandHistoryRow) {
Timber.d("Check keyboard for index = $index")
// Timber.d("Check keyboard for index = $index")
rowRepresentable.keyboardForCompletion()?.let { keyboard ->
return HHSelection(index, keyboard)
}

@ -105,11 +105,16 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr
findNextActionToEdit(0)
}
private fun findNextActionToEdit() {
val index = this.model.currentSelection?.index ?: throw PAIllegalStateException("Request next with no selection")
this.findNextActionToEdit(index)
}
private fun findNextActionToEdit(startIndex: Int) {
this.model.findIndexForEdition(startIndex)?.let {
// this.handHistoryAdapter.notifyItemChanged(startIndex)
this.keyboard.show(it)
this.highlightCell()
this.highlightCell(startIndex)
} ?: run {
this.keyboard.hide()
}
@ -119,9 +124,11 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr
this.model.isEdited = false
}
private fun highlightCell() {
private fun highlightCell(oldIndex: Int) {
this.handHistoryAdapter.notifyItemChanged(oldIndex)
this.model.currentSelection?.index?.let {
Timber.d("refreshes old = $oldIndex, new = $it")
this.handHistoryAdapter.notifyItemChanged(it)
}
@ -155,19 +162,21 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr
this.model.currentSelection = HHSelection(position, HHKeyboard.values()[tag])
when (row) {
val keyboard = when (row) {
is ComputedAction -> {
val keyboard = when (tag) {
when (tag) {
HHKeyboard.ACTION.ordinal -> HHKeyboard.ACTION
HHKeyboard.AMOUNT.ordinal -> HHKeyboard.AMOUNT
else -> throw PAIllegalStateException("Unmanaged tag value: $tag")
}
this.keyboard.show(keyboard)
}
is StreetCardHeader -> {
this.keyboard.show(HHKeyboard.CARD)
HHKeyboard.CARD
}
else -> null
}
Timber.d("row $position selected, show keyboard = $keyboard")
keyboard?.let { this.keyboard.show(keyboard) }
}
@ -183,7 +192,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr
val currentSelection = this.model.currentSelection
val isSelectedIndex = (position == currentSelection?.index)
val isSelectedAction = (tag == currentSelection?.keyboard?.ordinal)
Timber.d("position = $position, tag = $tag, current index = ${currentSelection?.index}, kb = ${currentSelection?.keyboard}")
// Timber.d("position = $position, tag = $tag, current index = ${currentSelection?.index}, kb = ${currentSelection?.keyboard}")
return isSelectedIndex && isSelectedAction
}
@ -193,7 +202,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr
Timber.d(">>> action $action selected")
this.model.actionSelected(action)
// this.handHistoryAdapter.notifyDataSetChanged()
this.findNextActionToEdit(this.model.actionIndexForSelection)
this.findNextActionToEdit()
}
override fun cardValueSelected(value: Int) {
@ -216,7 +225,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr
Timber.d(">>> amount validated")
this.model.amountValidated()
// this.handHistoryAdapter.notifyDataSetChanged()
this.findNextActionToEdit(this.model.actionIndexForSelection)
this.findNextActionToEdit()
}
}

@ -745,20 +745,32 @@ enum class RowViewType(private var layoutRes: Int) {
actionEditText.isFocusable = computedAction.actionTypeCanBeEdited
val selected = adapter.dataSource.isSelected(position, row, tag)
Timber.d("Action at $position is selected: $selected")
// Timber.d("Action at $position is selected: $selected")
actionEditText.setBackgroundColor(color(selected))
computedAction.action.type?.resId?.let {
actionEditText.setText(it)
} ?: run {
actionEditText.text = null
}
if (selected) actionEditText.requestFocus()
if (selected) actionEditText.requestFocus() else actionEditText.clearFocus()
actionEditText.setOnClickListener {
Timber.d("OnClickListener at $position")
val isSelected = adapter.dataSource.isSelected(position, row, tag)
if (!isSelected && computedAction.actionTypeCanBeEdited) {
actionEditText.requestFocus()
adapter.delegate?.onRowSelected(position, row, tag)
actionEditText.setBackgroundColor(color(true))
} else {
adapter.delegate?.onRowDeselected(position, row)
actionEditText.setBackgroundColor(color(false))
}
}
actionEditText.setOnFocusChangeListener { v, hasFocus ->
Timber.d("focus change = $hasFocus at position = $position")
actionEditText.setBackgroundColor(color(hasFocus))
}
@ -774,13 +786,16 @@ enum class RowViewType(private var layoutRes: Int) {
amountEditText.setText(computedAction.action.amount?.formatted())
if (selected) amountEditText.requestFocus()
if (selected) amountEditText.requestFocus() else amountEditText.clearFocus()
amountEditText.setOnClickListener {
amountEditText.setOnTouchListener { v, event ->
Timber.d("OnClickListener at $position")
adapter.delegate?.onRowSelected(position, row, tag)
amountEditText.setBackgroundColor(color(true))
return@setOnTouchListener true
}
amountEditText.setOnFocusChangeListener { v, hasFocus ->
Timber.d("focus change = $hasFocus at position = $position")
amountEditText.setBackgroundColor(color(hasFocus))
}
amountEditText.addTextChangedListener {

@ -9,7 +9,6 @@ import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.handhistory.HHKeyboard
import net.pokeranalytics.android.model.realm.handhistory.Action
import net.pokeranalytics.android.model.realm.handhistory.Card
import timber.log.Timber
interface KeyboardListener {
fun actionSelected(action: Action.Type)
@ -39,7 +38,7 @@ class KeyboardContainer(context: Context, attrs: AttributeSet?) : FrameLayout(co
}
fun show(type: HHKeyboard) {
Timber.d("show keyboard : $type")
// Timber.d("show keyboard : $type")
show()

@ -39,10 +39,10 @@ class HandHistoryViewModel : ViewModel() {
// this.builder.
}
val actionIndexForSelection: Int
private val actionIndexForSelection: Int
get() {
this.currentSelection?.let {
return builder.value?.indexOfComputedAction(it.index) ?: throw PAIllegalStateException("No builder")
this.currentSelection?.let { selection ->
return builder.value?.indexOfComputedAction(selection.index) ?: throw PAIllegalStateException("No builder")
} ?: throw PAIllegalStateException("No selection")
}

@ -29,6 +29,7 @@
android:id="@+id/actionEditText"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"

@ -783,7 +783,7 @@
<string name="fold">fold</string>
<string name="straddle">straddle</string>
<string name="check">check</string>
<string name="call">check</string>
<string name="call">call</string>
<string name="bet">bet</string>
<string name="raise">raise</string>
<string name="allin">allin</string>

Loading…
Cancel
Save