Fix crash when editing categories for global update or downloads

Fixes #949
This commit is contained in:
Jays2Kings 2021-08-23 00:45:23 -04:00
parent 372830b6d4
commit 1ce5f50d89

View File

@ -60,16 +60,10 @@ internal class QuadStateMultiChoiceDialogAdapter(
else -> QuadStateCheckBox.State.CHECKED.ordinal else -> QuadStateCheckBox.State.CHECKED.ordinal
} }
currentSelection = newSelection.toIntArray() currentSelection = newSelection.toIntArray()
val selectedItems = this.items.pullIndices(this.currentSelection) val selectedItems = this.items.filterIndexed { index, _ ->
selection?.invoke(dialog, currentSelection, selectedItems) currentSelection[index] != 0
}
internal inline fun <reified T> List<T>.pullIndices(indices: IntArray): List<T> {
return mutableListOf<T>().apply {
for (index in indices) {
add(this@pullIndices[index])
}
} }
selection?.invoke(dialog, currentSelection, selectedItems)
} }
override fun onCreateViewHolder( override fun onCreateViewHolder(