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