|
|
|
@ -117,32 +117,51 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
|
|
val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow |
|
|
|
val row = this.model.rowRepresentableForPosition(it.index) as HandHistoryRow |
|
|
|
|
|
|
|
|
|
|
|
val keyboard = row.keyboardForTag(it.tag) |
|
|
|
row.keyboardForTag(it.tag)?.let { keyboard -> |
|
|
|
when (keyboard) { |
|
|
|
|
|
|
|
HHKeyboard.ACTION -> { |
|
|
|
when (keyboard) { |
|
|
|
configureActionKeyboard() |
|
|
|
HHKeyboard.ACTION -> { |
|
|
|
} |
|
|
|
configureActionKeyboard() |
|
|
|
HHKeyboard.AMOUNT -> { |
|
|
|
} |
|
|
|
retrieveEditTextInputConnection(selection) |
|
|
|
HHKeyboard.AMOUNT -> { |
|
|
|
|
|
|
|
retrieveEditTextInputConnection(selection) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> {} |
|
|
|
} |
|
|
|
} |
|
|
|
else -> {} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keyboard?.let { |
|
|
|
this.showKeyboard(keyboard) { |
|
|
|
// this.animateKeyboard(true) |
|
|
|
|
|
|
|
this.showKeyboard(it) { |
|
|
|
|
|
|
|
this.scrollToPosition(selection.index) |
|
|
|
this.scrollToPosition(selection.index) |
|
|
|
} |
|
|
|
} |
|
|
|
// this.keyboard.show(it) |
|
|
|
|
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
this.animateKeyboard(false) |
|
|
|
this.animateKeyboard(false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// val keyboard = row.keyboardForTag(it.tag) |
|
|
|
|
|
|
|
// when (keyboard) { |
|
|
|
|
|
|
|
// HHKeyboard.ACTION -> { |
|
|
|
|
|
|
|
// configureActionKeyboard() |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// HHKeyboard.AMOUNT -> { |
|
|
|
|
|
|
|
// retrieveEditTextInputConnection(selection) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// else -> {} |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// keyboard?.let { kb -> |
|
|
|
|
|
|
|
//// this.animateKeyboard(true) |
|
|
|
|
|
|
|
// this.showKeyboard(kb) { |
|
|
|
|
|
|
|
// this.scrollToPosition(selection.index) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
//// this.keyboard.show(it) |
|
|
|
|
|
|
|
// } ?: run { |
|
|
|
|
|
|
|
// this.animateKeyboard(false) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
this.animateKeyboard(false) |
|
|
|
this.animateKeyboard(false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val observer = Observer<MutableList<RowRepresentable>> { |
|
|
|
val observer = Observer<MutableList<RowRepresentable>> { |
|
|
|
@ -162,7 +181,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
initKeyboard() |
|
|
|
initKeyboardDefaultHeight() |
|
|
|
this.keyboard.keyboardListener = this |
|
|
|
this.keyboard.keyboardListener = this |
|
|
|
this.keyboard.setCardCentralizer(this.model) |
|
|
|
this.keyboard.setCardCentralizer(this.model) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -185,6 +204,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
override fun onOptionsItemSelected(item: MenuItem?): Boolean { |
|
|
|
override fun onOptionsItemSelected(item: MenuItem?): Boolean { |
|
|
|
when (item!!.itemId) { |
|
|
|
when (item!!.itemId) { |
|
|
|
R.id.edit_save -> saveOrEdit() |
|
|
|
R.id.edit_save -> saveOrEdit() |
|
|
|
|
|
|
|
R.id.add -> addNewHand() |
|
|
|
|
|
|
|
R.id.delete -> deleteHand() |
|
|
|
|
|
|
|
R.id.back -> showPreviousHand() |
|
|
|
|
|
|
|
R.id.forward -> showNextHand() |
|
|
|
} |
|
|
|
} |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
@ -402,6 +425,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
// this.hideKeyboard() |
|
|
|
// this.hideKeyboard() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Method called when a shortcut [position] has been selected |
|
|
|
|
|
|
|
* Jumps the selection to the next action of the [position] |
|
|
|
|
|
|
|
*/ |
|
|
|
override fun positionSelected(position: Position) { |
|
|
|
override fun positionSelected(position: Position) { |
|
|
|
val rowRepresentableIndex = this.model.nextActionIndexForPosition(position) |
|
|
|
val rowRepresentableIndex = this.model.nextActionIndexForPosition(position) |
|
|
|
this.model.rowRepresentableForPosition(rowRepresentableIndex)?.let { |
|
|
|
this.model.rowRepresentableForPosition(rowRepresentableIndex)?.let { |
|
|
|
@ -438,7 +465,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Shows the given [keyboard] |
|
|
|
|
|
|
|
* Notifies the [endHandler] when the keyboard has finished animating |
|
|
|
|
|
|
|
*/ |
|
|
|
private fun showKeyboard(keyboard: HHKeyboard, endHandler: (() -> (Unit))? = null) { |
|
|
|
private fun showKeyboard(keyboard: HHKeyboard, endHandler: (() -> (Unit))? = null) { |
|
|
|
|
|
|
|
|
|
|
|
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
@ -448,6 +478,11 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
this.keyboard.show(keyboard) |
|
|
|
this.keyboard.show(keyboard) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Animates the keyboard |
|
|
|
|
|
|
|
* [show] defines whether the keyboard should be shown or hidden |
|
|
|
|
|
|
|
* Notifies the [endHandler] when the keyboard has finished animating |
|
|
|
|
|
|
|
*/ |
|
|
|
private fun animateKeyboard(show: Boolean, endHandler: (() -> (Unit))? = null) { |
|
|
|
private fun animateKeyboard(show: Boolean, endHandler: (() -> (Unit))? = null) { |
|
|
|
|
|
|
|
|
|
|
|
val height = 310.0f.px |
|
|
|
val height = 310.0f.px |
|
|
|
@ -474,10 +509,43 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
valueAnimator.start() |
|
|
|
valueAnimator.start() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
private fun initKeyboard() { |
|
|
|
* Starts by hiding the keyboard |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun initKeyboardDefaultHeight() { |
|
|
|
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
lp.guideEnd = 0 |
|
|
|
lp.guideEnd = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun showNextHand() { |
|
|
|
|
|
|
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun showPreviousHand() { |
|
|
|
|
|
|
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Deletes the current hand |
|
|
|
|
|
|
|
* Finishes the activity to go back |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun deleteHand() { |
|
|
|
|
|
|
|
if (this.model.handHistory.isManaged) { |
|
|
|
|
|
|
|
getRealm().executeTransaction { |
|
|
|
|
|
|
|
this.model.handHistory.deleteFromRealm() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.activity?.finish() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Creates a new hand using the current hand setup |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun addNewHand() { |
|
|
|
|
|
|
|
getRealm().executeTransaction { |
|
|
|
|
|
|
|
this.model.createNewHandHistoryWithCurrentSetup(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.findNextActionToEdit(0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |