|
|
|
@ -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 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|