diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt index 143acc07..1a891360 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt @@ -101,6 +101,26 @@ class HandHistoryAdapter( } + inner class RowHandActionTest(itemView: View) : RowHandHolder(itemView), BindableHolder { + + override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { + + val computedAction = row as ComputedAction + itemView.findViewById(R.id.amountEditText)?.let { amountEditText -> +// amountEditText.setText(computedAction.action.formattedAmount) + + val selected = adapter.dataSource.isSelected(position, row, 0) + if (selected) { + amountEditText.requestFocus() + } else { + amountEditText.clearFocus() + } + } + + } + + } + /** * Display a hand action */ 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 373b806e..3694f0c9 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 @@ -68,11 +68,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL initUI() this.edit() -// this.model.selectionLiveData.value?.index?.let { -// Timber.d(">>>> attempt to retrieveEditTextInputConnection") -// this.retrieveEditTextInputConnection(it) -// } - } private fun initData() { @@ -127,8 +122,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL // At first, the selection is defined before the holder is bound, // so we retrieve the editText inputConnection once the recycler view has been rendered this.recyclerView.viewTreeObserver.addOnGlobalLayoutListener { - this.model.selectionLiveData.value?.index?.let { - retrieveEditTextInputConnection(it) + this.model.selectionLiveData.value?.let { selection -> + if (selection.keyboard == HHKeyboard.AMOUNT) { + retrieveEditTextInputConnection(selection.index) + } } } @@ -140,7 +137,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL val computedAction = this.model.rowRepresentableForPosition(position) as? ComputedAction - val holder = recyclerView.findViewHolderForAdapterPosition(position) as? HandHistoryAdapter.RowHandAction + val holder = recyclerView.findViewHolderForAdapterPosition(position) holder?.let { val amountEditText = it.itemView.findViewById(R.id.amountEditText) this.keyboard.setAmountEditText(amountEditText, computedAction?.action?.amount) @@ -173,7 +170,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL } ?: run { this.keyboard.hide() } - this.refreshCells(startIndex) + this.handHistoryAdapter.notifyDataSetChanged() +// this.refreshCells(startIndex) } override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) { @@ -283,9 +281,12 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL this.findNextActionToEdit() } + override fun amountChanged(amount: String?) { + this.model.amountChanged(amount) + } + override fun amountCleared() { this.model.clearAmount() -// this.refreshCurrentRow() } override fun closeKeyboard() { @@ -296,10 +297,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL this.keyboard?.hide() } - override fun amountChanged(amount: String?) { - this.model.amountChanged(amount) - } - override fun positionSelected(position: Position) { val rowRepresentableIndex = this.model.nextActionIndexForPosition(position) this.model.rowRepresentableForPosition(rowRepresentableIndex)?.let { diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardAmountView.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardAmountView.kt index 5896bb8f..20fa9030 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardAmountView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardAmountView.kt @@ -116,7 +116,7 @@ class KeyboardAmountView(context: Context) : AbstractKeyboardView(context), this.editText = editText editText.setText(amount?.noGroupingFormatted) -// editText.requestFocus() + editText.requestFocus() editText.isEnabled = true // avoid crashes due to input connection null editText.onCreateInputConnection(EditorInfo())?.let { @@ -158,11 +158,6 @@ class KeyboardAmountView(context: Context) : AbstractKeyboardView(context), else -> { it.commitText(key.value, 1) } } -// Timber.d(">>> text = ${this.editText.text.toString()}") -// this.editText?.setText(this.editText?.text) - -// this.editText?.forceLayout() - this.keyboardListener?.amountChanged(this.editText.text.toString()) } ?: run {