diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt index 7adf515e..da5ea31c 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt @@ -139,38 +139,9 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL // itemTouchHelper.attachToRecyclerView(this) } + // Observe the selection changes to display the appropriate keyboard this.model.selectionLiveData.observeForever { selection -> - 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) - } - + manageKeyboard(selection) } val observer = Observer> { @@ -241,6 +212,44 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL 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 */ diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardContainer.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardContainer.kt index 93c74c11..09aac022 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardContainer.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardContainer.kt @@ -67,6 +67,7 @@ class KeyboardContainer : FrameLayout { KeyboardCardView(context) } } + view.visibility = View.GONE this.keyboards[it] = view addView(view) }