Laurent 6 years ago
parent 6976aa7c63
commit 028d6eaf65
  1. 10
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HHBuilder.kt
  2. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  3. 15
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  4. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardAmountView.kt
  5. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt

@ -130,7 +130,7 @@ class HHBuilder {
val actionAmount = lastSignificantAction.action.amount
when (lastSignificantAction.action.type) {
Action.Type.POST_BB, Action.Type.STRADDLE -> {
Action.Type.POST_SB, Action.Type.POST_BB, Action.Type.STRADDLE -> {
if (position == lastSignificantAction.position) {
setOf(Action.Type.FOLD, Action.Type.CHECK, Action.Type.BET, Action.Type.UNDEFINED_ALLIN)
} else {
@ -522,9 +522,9 @@ class HHBuilder {
*/
private fun getLastUserAction(index: Int): ComputedAction? {
val action = this.actionForIndex(index).action
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
// Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
val previousActions = this.sortedActions.take(index)
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
// Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
return previousActions.lastOrNull { it.action.position == action.position }
}
@ -533,9 +533,9 @@ class HHBuilder {
*/
private fun getStreetLastSignificantAction(index: Int): ComputedAction? {
val street = this.actionForIndex(index).action.street
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
// Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
val previousActions = this.sortedActions.take(index).filter { it.action.street == street }
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
// Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}")
return previousActions.lastOrNull { it.action.isActionSignificant }
}

@ -170,11 +170,7 @@ class HandHistoryAdapter(
val tag = HHKeyboard.ACTION.ordinal
val selected = adapter.dataSource.isSelected(position, row, tag)
// Timber.d("Action at $position is selected: $selected")
actionButton.backgroundTintList = ColorStateList.valueOf(color(selected))
// if (selected) {
// (itemView.context as Activity).hideKeyboard()
// }
computedAction.action.type?.resId?.let {
actionButton.setText(it)
@ -191,12 +187,11 @@ class HandHistoryAdapter(
val tag = HHKeyboard.AMOUNT.ordinal
val selected = adapter.dataSource.isSelected(position, row, tag)
amountEditText.setBackgroundColor(color(selected))
// Both are required, otherwise requestFocus() fails
amountEditText.isFocusable = selected && computedAction.amountCanBeEdited
amountEditText.isFocusableInTouchMode = selected && computedAction.amountCanBeEdited
amountEditText.setBackgroundColor(color(selected))
// amountEditText.isFocusable = selected && computedAction.amountCanBeEdited
// amountEditText.isFocusableInTouchMode = selected && computedAction.amountCanBeEdited
amountEditText.setText(computedAction.action.formattedAmount)

@ -10,7 +10,9 @@ import kotlinx.android.synthetic.main.fragment_hand_history.*
import kotlinx.android.synthetic.main.fragment_settings.recyclerView
import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.handhistory.*
import net.pokeranalytics.android.model.handhistory.ComputedAction
import net.pokeranalytics.android.model.handhistory.HandSetup
import net.pokeranalytics.android.model.handhistory.Position
import net.pokeranalytics.android.model.realm.handhistory.Action
import net.pokeranalytics.android.model.realm.handhistory.Card
import net.pokeranalytics.android.model.realm.handhistory.HandHistory
@ -94,8 +96,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
setDisplayHomeAsUpEnabled(true)
// SmoothScrollLinearLayoutManager(requireContext())
// val viewManager = LinearLayoutManager(requireContext())
this.handHistoryAdapter = HandHistoryAdapter(this.model,this)
recyclerView.apply {
@ -150,20 +150,13 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
private fun edit() {
this.model.isEdited = true
findNextActionToEdit(0)
// this.handHistoryAdapter.notifyDataSetChanged()
this.findNextActionToEdit(0)
}
private fun closeEdition() {
this.model.isEdited = false
}
// private fun findNextActionToEdit() {
// val selection = this.model.selectionLiveData.value
// val index = selection?.index ?: throw PAIllegalStateException("Request next with no selection")
// this.findNextActionToEdit(index, selection.keyboard)
// }
private fun findNextActionToEdit(index: Int? = null) {
val startIndex = index ?: this.model.currentSelection.index
this.model.findIndexForEdition(startIndex)?.let { selection ->

@ -17,7 +17,6 @@ import net.pokeranalytics.android.ui.view.GridSpacingItemDecoration
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.util.extensions.noGroupingFormatted
import timber.log.Timber
import java.text.DecimalFormatSymbols
class NumericKey : RowRepresentable {
@ -29,6 +28,9 @@ class NumericKey : RowRepresentable {
constructor(type: Type) {
this.type = type
if (type == Type.DECIMAL) {
this.value = DecimalFormatSymbols.getInstance().decimalSeparator.toString()
}
}
constructor(number: Int) : this(Type.NUMBER) {
@ -106,6 +108,7 @@ class KeyboardAmountView(context: Context) : AbstractKeyboardView(context),
editText.setText(amount?.noGroupingFormatted)
this.inputConnection = editText.onCreateInputConnection(EditorInfo())
}
override fun adapterRows(): List<RowRepresentable>? {
@ -132,15 +135,15 @@ class KeyboardAmountView(context: Context) : AbstractKeyboardView(context),
when {
key.isBackSpace -> { it.deleteSurroundingText(1, 0) }
key.isDecimalSeparator -> {
val text = it.getSelectedText(0)
if (text != null && !text.contains(key.value)) {
val text = this.editText.text.toString()
if (!text.contains(key.value)) {
it.commitText(key.value, 1)
}
}
else -> { it.commitText(key.value, 1) }
}
Timber.d(">>> text = ${this.editText.text.toString()}")
// Timber.d(">>> text = ${this.editText.text.toString()}")
// this.editText?.setText(this.editText?.text)
// this.editText?.forceLayout()

@ -94,7 +94,7 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
val color = if (enabled) {
R.color.kaki_light
} else {
R.color.green_darkest
R.color.kaki
}
it.setBackgroundColor(itemView.context.getColor(color))
it.isEnabled = enabled

Loading…
Cancel
Save