list: fix sort dialog allowing invalid sorts
If you changed the mode but disabled the direction, you would wind up with an outright invalid sort that you could still save. Fix that.
This commit is contained in:
parent
97b0a8aa68
commit
018e142ee9
1 changed files with 3 additions and 3 deletions
|
@ -96,17 +96,17 @@ abstract class SortDialog :
|
|||
|
||||
private fun updateButtons() {
|
||||
val binding = requireBinding()
|
||||
binding.sortSave.isEnabled = getCurrentSort() != getInitialSort()
|
||||
binding.sortSave.isEnabled = getCurrentSort().let { it != null && it != getInitialSort() }
|
||||
}
|
||||
|
||||
private fun getCurrentSort(): Sort? {
|
||||
val initial = getInitialSort()
|
||||
val mode = modeAdapter.currentMode ?: initial?.mode ?: return null
|
||||
val mode = modeAdapter.currentMode ?: return null
|
||||
val direction =
|
||||
when (requireBinding().sortDirectionGroup.checkedButtonId) {
|
||||
R.id.sort_direction_asc -> Sort.Direction.ASCENDING
|
||||
R.id.sort_direction_dsc -> Sort.Direction.DESCENDING
|
||||
else -> initial?.direction ?: return null
|
||||
else -> return null
|
||||
}
|
||||
return Sort(mode, direction)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue