|
|
|
@ -105,16 +105,17 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
|
|
val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow |
|
|
|
val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow |
|
|
|
|
|
|
|
|
|
|
|
when (row.keyboardForTag(it.tag)) { |
|
|
|
val keyboard = row.keyboardForTag(it.tag) |
|
|
|
|
|
|
|
when (keyboard) { |
|
|
|
HHKeyboard.ACTION -> { |
|
|
|
HHKeyboard.ACTION -> { |
|
|
|
val positions = this.model.positionsToAct() |
|
|
|
configureActionKeyboard() |
|
|
|
this.keyboard.setPositions(positions) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
HHKeyboard.AMOUNT -> { |
|
|
|
HHKeyboard.AMOUNT -> { |
|
|
|
retrieveEditTextInputConnection(selection) |
|
|
|
retrieveEditTextInputConnection(selection) |
|
|
|
} |
|
|
|
} |
|
|
|
else -> {} |
|
|
|
else -> {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.keyboard.show(keyboard) |
|
|
|
|
|
|
|
|
|
|
|
// when (row) { |
|
|
|
// when (row) { |
|
|
|
// is ComputedAction -> { |
|
|
|
// is ComputedAction -> { |
|
|
|
@ -145,7 +146,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
// At first, the selection is defined before the holder is bound, |
|
|
|
// At first, the selection is defined before the holder is bound, |
|
|
|
// so we retrieve the editText inputConnection once the recycler view has been rendered |
|
|
|
// so we retrieve the editText inputConnection once the recycler view has been rendered |
|
|
|
this.recyclerView.viewTreeObserver.addOnGlobalLayoutListener { |
|
|
|
this.recyclerView.viewTreeObserver.addOnGlobalLayoutListener { |
|
|
|
|
|
|
|
|
|
|
|
when (this.model.currentKeyboard) { |
|
|
|
when (this.model.currentKeyboard) { |
|
|
|
HHKeyboard.AMOUNT -> { |
|
|
|
HHKeyboard.AMOUNT -> { |
|
|
|
val selection = this.model.currentSelection |
|
|
|
val selection = this.model.currentSelection |
|
|
|
@ -153,12 +153,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
} |
|
|
|
} |
|
|
|
else -> {} |
|
|
|
else -> {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.keyboard.keyboardListener = this |
|
|
|
this.keyboard.keyboardListener = this |
|
|
|
this.keyboard.setCardCentralizer(this.model) |
|
|
|
this.keyboard.setCardCentralizer(this.model) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun retrieveEditTextInputConnection(selection: HHSelection) { |
|
|
|
private fun retrieveEditTextInputConnection(selection: HHSelection) { |
|
|
|
@ -188,17 +186,16 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
val startIndex = index ?: this.model.currentSelection.index |
|
|
|
val startIndex = index ?: this.model.currentSelection.index |
|
|
|
this.model.findSelectionForEdition(startIndex)?.let { selection -> |
|
|
|
this.model.findSelectionForEdition(startIndex)?.let { selection -> |
|
|
|
|
|
|
|
|
|
|
|
this.recyclerView.smoothScrollToPosition(selection.index) |
|
|
|
this.scrollToPosition(selection.index) |
|
|
|
|
|
|
|
|
|
|
|
this.model.currentKeyboard?.let { keyboard -> |
|
|
|
// this.model.currentKeyboard?.let { keyboard -> |
|
|
|
when (keyboard) { |
|
|
|
// when (keyboard) { |
|
|
|
HHKeyboard.ACTION -> { |
|
|
|
// HHKeyboard.ACTION -> { |
|
|
|
val availableActions = this.model.availableActions() |
|
|
|
// configureActionKeyboard() |
|
|
|
this.keyboard.setAvailableAction(availableActions) |
|
|
|
// } else -> {} |
|
|
|
} else -> {} |
|
|
|
// } |
|
|
|
} |
|
|
|
// this.keyboard.show(keyboard) |
|
|
|
this.keyboard.show(keyboard) |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
this.keyboard.hide() |
|
|
|
this.keyboard.hide() |
|
|
|
@ -222,20 +219,25 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
refreshCells(oldIndex) |
|
|
|
refreshCells(oldIndex) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// scrolls to selected position |
|
|
|
this.scrollToPosition(position) |
|
|
|
this.recyclerView.smoothScrollToPosition(position) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.model.selectionLiveData.value = HHSelection(position, tag) |
|
|
|
this.model.selectionLiveData.value = HHSelection(position, tag) |
|
|
|
|
|
|
|
|
|
|
|
val keyboard = (row as HandHistoryRow).keyboardForTag(tag) |
|
|
|
// val keyboard = (row as HandHistoryRow).keyboardForTag(tag) |
|
|
|
if (keyboard == HHKeyboard.ACTION) { |
|
|
|
// if (keyboard == HHKeyboard.ACTION) { |
|
|
|
val availableActions = this.model.availableActions() |
|
|
|
// configureActionKeyboard() |
|
|
|
this.keyboard.setAvailableAction(availableActions) |
|
|
|
// } |
|
|
|
} |
|
|
|
// this.keyboard.show(keyboard) |
|
|
|
|
|
|
|
|
|
|
|
Timber.d("row $position selected, show keyboard = $keyboard") |
|
|
|
// Timber.d("row $position selected, show keyboard = $keyboard") |
|
|
|
this.keyboard.show(keyboard) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun configureActionKeyboard() { |
|
|
|
|
|
|
|
val availableActions = this.model.availableActions() |
|
|
|
|
|
|
|
this.keyboard.setAvailableAction(availableActions) |
|
|
|
|
|
|
|
val positions = this.model.positionsToAct() |
|
|
|
|
|
|
|
this.keyboard.setPositions(positions) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onRowDeselected(position: Int, row: RowRepresentable) { |
|
|
|
override fun onRowDeselected(position: Int, row: RowRepresentable) { |
|
|
|
@ -321,7 +323,15 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
} ?: throw PAIllegalStateException("Rowrepresentable not fouind at index $rowRepresentableIndex") |
|
|
|
} ?: throw PAIllegalStateException("Rowrepresentable not fouind at index $rowRepresentableIndex") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Table refresh |
|
|
|
// Table |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Scrolls to the [index] |
|
|
|
|
|
|
|
* We subtract 1 to give space and the ability to see the previously entered data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun scrollToPosition(index: Int) { |
|
|
|
|
|
|
|
this.recyclerView.smoothScrollToPosition(index - 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun refreshCells(oldIndex: Int) { |
|
|
|
private fun refreshCells(oldIndex: Int) { |
|
|
|
this.handHistoryAdapter.notifyItemChanged(oldIndex) |
|
|
|
this.handHistoryAdapter.notifyItemChanged(oldIndex) |
|
|
|
|