|
|
|
|
@ -91,11 +91,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
|
initData() |
|
|
|
|
initUI() |
|
|
|
|
|
|
|
|
|
// if (this.model.isEdited) { |
|
|
|
|
// this.findNextActionToEdit(0) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
|
@ -191,7 +186,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
initKeyboardDefaultHeight() |
|
|
|
|
this.keyboard.keyboardListener = this |
|
|
|
|
// this.keyboard.setCardCentralizer(this.model) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { |
|
|
|
|
@ -344,58 +338,40 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
|
|
|
|
|
|
|
|
|
getRealm().executeTransaction { |
|
|
|
|
|
|
|
|
|
when (row) { |
|
|
|
|
HandRowType.COMMENT -> { |
|
|
|
|
this.model.handHistory.comment = value as? String |
|
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.indexOfRowRepresentable(row)) |
|
|
|
|
} |
|
|
|
|
HandRowType.PLAYER_NUMBER -> { |
|
|
|
|
this.model.setNumberOfPlayers(value as Int) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
HandRowType.ANTE -> { |
|
|
|
|
this.model.setAnte(value as Double? ?: 0.0) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
HandRowType.BIG_BLIND_ANTE -> { |
|
|
|
|
this.model.setBigBlindAnte(value as Boolean) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
HandRowType.HERO_POSITION -> { |
|
|
|
|
this.model.setHeroPosition(value as Position) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
when (row) { |
|
|
|
|
HandRowType.COMMENT -> { |
|
|
|
|
this.model.handHistory.comment = value as? String |
|
|
|
|
this.handHistoryAdapter.notifyItemChanged(this.indexOfRowRepresentable(row)) |
|
|
|
|
} |
|
|
|
|
HandRowType.PLAYER_NUMBER -> { |
|
|
|
|
this.model.setNumberOfPlayers(value as Int) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
HandRowType.ANTE -> { |
|
|
|
|
this.model.setAnte(value as Double? ?: 0.0) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
HandRowType.BIG_BLIND_ANTE -> { |
|
|
|
|
this.model.setBigBlindAnte(value as Boolean) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
HandRowType.HERO_POSITION -> { |
|
|
|
|
this.model.setHeroPosition(value as Position) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
// this.handHistoryAdapter.notifyItemChanged(this.indexOfRowRepresentable(row)) |
|
|
|
|
} |
|
|
|
|
HandRowType.PLAYER_POSITION -> { |
|
|
|
|
this.model.createPlayerSetupForPosition(value as Position) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
is ComputedAction -> { |
|
|
|
|
this.model.currentAmount = value as String |
|
|
|
|
} |
|
|
|
|
is StraddleRowRepresentable -> { |
|
|
|
|
this.model.changeStraddleSelection(value as LinkedHashSet<Position>) |
|
|
|
|
} |
|
|
|
|
// is PlayerSetupRow -> { |
|
|
|
|
// when (value) { |
|
|
|
|
// is Position -> { |
|
|
|
|
// this.model.setPlayerSetupPosition(row, value) |
|
|
|
|
// val index = this.indexOfRowRepresentable(row) |
|
|
|
|
// this.handHistoryAdapter.notifyItemChanged(index) |
|
|
|
|
// |
|
|
|
|
// // Change the focus only for the row, don't look elsewhere |
|
|
|
|
//// val anyEmpty = row.tagsForCompletion().any { row.isFieldNeedsInput(it, this.model.handHistory) } |
|
|
|
|
//// if (anyEmpty) { |
|
|
|
|
//// this.findNextActionToEdit(index) |
|
|
|
|
//// } |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HandRowType.PLAYER_POSITION -> { |
|
|
|
|
this.model.createPlayerSetupForPosition(value as Position) |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
is ComputedAction -> { |
|
|
|
|
this.model.currentAmount = value as String |
|
|
|
|
} |
|
|
|
|
is StraddleRowRepresentable -> { |
|
|
|
|
this.model.changeStraddleSelection(value as LinkedHashSet<Position>) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onItemClick(position: Int, row: RowRepresentable, tag: Int) { |
|
|
|
|
@ -404,15 +380,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
is PositionalRow -> { |
|
|
|
|
this.model.tappedPlayerPositionIndex = row.positionIndex |
|
|
|
|
DataListActivity.newDialogInstance(this, LiveData.PLAYER, true) |
|
|
|
|
// when (tag) { |
|
|
|
|
// PlayerSetupRow.Tag.PLAYER.ordinal -> { |
|
|
|
|
// this.model.clickPlayerPosition = position |
|
|
|
|
// DataListActivity.newDialogInstance(this, LiveData.PLAYER, true) |
|
|
|
|
// } |
|
|
|
|
// else -> { |
|
|
|
|
// Timber.d("onItemClick not configured for row: $row, position: $position, tag: $tag") |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -429,9 +396,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
|
|
|
|
|
override fun actionSelected(action: Action.Type) { |
|
|
|
|
Timber.d(">>> action $action selected") |
|
|
|
|
getRealm().executeTransaction { |
|
|
|
|
this.model.actionSelected(action) |
|
|
|
|
} |
|
|
|
|
this.model.actionSelected(action) |
|
|
|
|
this.findNextActionToEdit() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -565,7 +530,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
val start = if (show) 0.0f else height |
|
|
|
|
val end = if (show) height else 0.0f |
|
|
|
|
|
|
|
|
|
// val end = (this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams).guideEnd |
|
|
|
|
val valueAnimator = ValueAnimator.ofFloat(start, end) |
|
|
|
|
valueAnimator.duration = 150L |
|
|
|
|
// set duration |
|
|
|
|
@ -606,9 +570,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
* Finishes the activity to go back |
|
|
|
|
*/ |
|
|
|
|
private fun deleteHand() { |
|
|
|
|
// if (this.model.handHistory.isManaged) { |
|
|
|
|
// this.model.handHistory.deleteFromRealm() |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
getRealm().findById<HandHistory>(this.model.handHistory.id)?.let { hh -> |
|
|
|
|
getRealm().executeTransaction { |
|
|
|
|
|