|
|
|
|
@ -289,8 +289,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
/*** |
|
|
|
|
* Looks for a row and a keyboard, i.e. a HHSelection, suitable for edition |
|
|
|
|
*/ |
|
|
|
|
fun findSelectionForEdition(index: Int, minTag: Int?): HHSelection? { |
|
|
|
|
val selection = this.getSelectionForFirstIncompleteRow(index, minTag) |
|
|
|
|
fun findSelectionForEdition(index: Int, minTag: Int?, userInitiated: Boolean): HHSelection? { |
|
|
|
|
val selection = this.getSelectionForFirstIncompleteRow(index, minTag, userInitiated) |
|
|
|
|
this.selectionLiveData.value = selection |
|
|
|
|
return selection |
|
|
|
|
} |
|
|
|
|
@ -299,7 +299,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
* Finds the index of the first incomplete action, if existing |
|
|
|
|
* If the same selection is the same than current, pass to the next row |
|
|
|
|
*/ |
|
|
|
|
private fun getSelectionForFirstIncompleteRow(startIndex: Int, minTag: Int?): HHSelection? { |
|
|
|
|
private fun getSelectionForFirstIncompleteRow(startIndex: Int, minTag: Int?, userInitiated: Boolean): HHSelection? { |
|
|
|
|
|
|
|
|
|
this.rowRepresentables.forEachIndexed { index, rowRepresentable -> |
|
|
|
|
|
|
|
|
|
@ -307,15 +307,15 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
|
|
|
|
|
val tags = rowRepresentable.tagsForCompletion() |
|
|
|
|
when { |
|
|
|
|
index == startIndex && minTag != null -> { |
|
|
|
|
userInitiated && minTag != null && index == startIndex -> { |
|
|
|
|
tags.firstOrNull { |
|
|
|
|
it > minTag && rowRepresentable.isFieldEmpty(it, this.handHistory) |
|
|
|
|
it > minTag && rowRepresentable.isFieldNeedsInput(it, this.handHistory) |
|
|
|
|
}?.let { |
|
|
|
|
return HHSelection(index, it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
index >= startIndex -> { |
|
|
|
|
tags.firstOrNull { rowRepresentable.isFieldEmpty(it, this.handHistory) }?.let { tag -> |
|
|
|
|
tags.firstOrNull { rowRepresentable.isFieldNeedsInput(it, this.handHistory) }?.let { tag -> |
|
|
|
|
return HHSelection(index, tag) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|