Fixes visual bug

hh
Laurent 6 years ago
parent 30a0101c44
commit a74833ac5d
  1. 71
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  2. 1
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardContainer.kt

@ -139,38 +139,9 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
// itemTouchHelper.attachToRecyclerView(this) // itemTouchHelper.attachToRecyclerView(this)
} }
// Observe the selection changes to display the appropriate keyboard
this.model.selectionLiveData.observeForever { selection -> this.model.selectionLiveData.observeForever { selection ->
selection?.let { manageKeyboard(selection)
Timber.d("Current selection is ${selection.index} / ${selection.tag}")
val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow
row.onSelect(selection.tag)
val keyboard = row.keyboardForTag(it.tag)
keyboard?.let { kb ->
when (kb) {
HHKeyboard.ACTION -> {
configureActionKeyboard()
}
HHKeyboard.AMOUNT -> {
retrieveEditTextInputConnection(selection)
}
else -> {}
}
this.showKeyboard(kb) {
this.scrollToPosition(selection.index)
}
} ?: run {
this.animateKeyboard(false)
}
} ?: run {
this.animateKeyboard(false)
}
} }
val observer = Observer<MutableList<RowRepresentable>> { val observer = Observer<MutableList<RowRepresentable>> {
@ -241,6 +212,44 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
return true return true
} }
/***
* Shows or hide the keyboard depending on the [selection]
*/
private fun manageKeyboard(selection: HHSelection?) {
selection?.let {
Timber.d("Current selection is ${selection.index} / ${selection.tag}")
val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow
row.onSelect(selection.tag)
val keyboard = row.keyboardForTag(it.tag)
keyboard?.let { kb ->
when (kb) {
HHKeyboard.ACTION -> {
configureActionKeyboard()
}
HHKeyboard.AMOUNT -> {
retrieveEditTextInputConnection(selection)
}
else -> {}
}
this.showKeyboard(kb) {
this.scrollToPosition(selection.index)
}
} ?: run {
this.animateKeyboard(false)
}
} ?: run {
this.animateKeyboard(false)
}
}
/*** /***
* Defines if the UI should be in edit mode, or read mode if [editing] false * Defines if the UI should be in edit mode, or read mode if [editing] false
*/ */

@ -67,6 +67,7 @@ class KeyboardContainer : FrameLayout {
KeyboardCardView(context) KeyboardCardView(context)
} }
} }
view.visibility = View.GONE
this.keyboards[it] = view this.keyboards[it] = view
addView(view) addView(view)
} }

Loading…
Cancel
Save