MultiSelectDialog: put common choices on top even when selected

This commit is contained in:
johan12345
2021-10-09 13:44:17 +02:00
parent e2bcf8d1cd
commit aad386ab04

View File

@@ -81,9 +81,10 @@ class MultiSelectDialog : AppCompatDialogFragment() {
.sortedBy { it.value.toLowerCase(Locale.getDefault()) }
.sortedBy {
when {
selected.contains(it.key) -> 0
commonChoices?.contains(it.key) == true -> 1
else -> 2
selected.contains(it.key) && commonChoices?.contains(it.key) == true -> 0
selected.contains(it.key) -> 1
commonChoices?.contains(it.key) == true -> 2
else -> 3
}
}
.map { MultiSelectItem(it.key, it.value, it.key in selected) }