MultiSelectDialog: move selected entries to the top

fixes #126
This commit is contained in:
Johan von Forstner
2021-09-26 15:53:05 +02:00
parent 6cb8940696
commit 0e93e310bf

View File

@@ -79,7 +79,13 @@ class MultiSelectDialog : AppCompatDialogFragment() {
items = data.entries.toList()
.sortedBy { it.value.toLowerCase(Locale.getDefault()) }
.sortedByDescending { commonChoices?.contains(it.key) == true }
.sortedBy {
when {
selected.contains(it.key) -> 0
commonChoices?.contains(it.key) == true -> 1
else -> 2
}
}
.map { MultiSelectItem(it.key, it.value, it.key in selected) }
adapter.submitList(items)