Laurent 6 years ago
parent d09c7273d9
commit 581efbf84f
  1. 17
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  2. 3
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  3. 3
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt

@ -39,6 +39,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.holder.RowViewHolder
import net.pokeranalytics.android.ui.view.rowrepresentable.ViewIdentifier
import net.pokeranalytics.android.util.extensions.formatted
import timber.log.Timber
enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable {
@ -166,13 +167,18 @@ class HandHistoryAdapter(
fun editTextSelected(editText: EditText) {
// editText.setBackgroundColor(color(selected))
val row = dataSource.rowRepresentableForPosition(this.currentPosition)
?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition")
delegate?.onRowSelected(this.currentPosition, row, editText.tag as Int)
val tag = editText.tag as Int
setEditTextBackground(editText, true, true)
delegate?.onRowSelected(this.currentPosition, row, tag)
// val text = dataSource.charSequenceForRow(row, itemView.context, tag)
// editText.hint = text
// editText.text = null
setEditTextBackground(editText = editText, isEnabled = true, isFocused = true)
}
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
@ -435,10 +441,6 @@ class HandHistoryAdapter(
itemView.action_container.background = background
}
// actionReadRow.action?.let { type ->
// itemView.actionText.setTextColor(itemView.context.getColor(type.color))
// }
itemView.amountText.text = actionReadRow.amount?.formatted
}
@ -466,6 +468,7 @@ class HandHistoryAdapter(
amountEditText.setOnTouchListener { _, event ->
Timber.d("=== event.action = ${event.action}")
if (event.action == MotionEvent.ACTION_UP) {
// Both are required, otherwise requestFocus() fails
amountEditText.isFocusable = true

@ -358,7 +358,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun onRowDeselected(position: Int, row: RowRepresentable) {
this.model.clearSelection()
this.model.currentAmount = null
}
override fun onRowValueChanged(value: Any?, row: RowRepresentable) {
@ -391,7 +390,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
this.handHistoryAdapter.notifyDataSetChanged()
}
is ComputedAction -> {
this.model.currentAmount = value as String
this.model.amountChanged(value as String)
}
is StraddleRowRepresentable -> {
this.model.changeStraddleSelection(value as LinkedHashSet<Position>)

@ -93,6 +93,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
fun clearSelection() {
this.selectionLiveData.value = null
this.currentAmount = null
}
fun hasSelection(): Boolean {
@ -120,7 +121,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
/***
* The current amount edited by the user
*/
var currentAmount: String? = null
private var currentAmount: String? = null
/***
* The action index

Loading…
Cancel
Save