Some light refactoring

hh
Laurent 6 years ago
parent cb055bcaa3
commit 2a78b7e386
  1. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  2. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ActionList.kt
  3. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt

@ -37,8 +37,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
private lateinit var handHistoryAdapter: HandHistoryAdapter
// private var rows: List<RowRepresentable> = listOf()
companion object {
fun newInstance(id: String? = null): HandHistoryFragment {
@ -108,7 +106,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
when (it.keyboard) {
HHKeyboard.ACTION -> {
val positions = this.model.positionsForSelection()
val positions = this.model.positionsToAct()
this.keyboard.setPositions(positions)
}
HHKeyboard.AMOUNT -> {
@ -245,13 +243,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun actionSelected(action: Action.Type) {
Timber.d(">>> action $action selected")
this.model.actionSelected(action)
// indexesToRefresh?.let { indexes ->
// indexes.forEach { this.handHistoryAdapter.notifyItemChanged(it) }
// } ?: run {
// this.handHistoryAdapter.notifyDataSetChanged()
// }
this.findNextActionToEdit()
}

@ -511,7 +511,7 @@ class ActionList(var listener: ActionListListener) : ArrayList<ComputedAction>()
/***
* Returns all positions of the street, identified by the action at the given [index]
*/
fun positionsAtIndex(index: Int): List<Position> {
fun positionsToActAfterIndex(index: Int): List<Position> {
val currentStreet = this[index].street
val streetActions = this.filter { it.street == currentStreet }
return streetActions.drop(index + 1).map { it.position }

@ -150,10 +150,10 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
}
/***
* Returns a list of positions at the provided [index]
* Returns a list of positions that needs to act [index]
*/
fun positionsForSelection(): List<Position> {
return this.sortedActions.positionsAtIndex(this.actionIndexForSelection)
fun positionsToAct(): List<Position> {
return this.sortedActions.positionsToActAfterIndex(this.actionIndexForSelection)
}
/***

Loading…
Cancel
Save