3
3
Fork 1
mirror of https://github.com/recloudstream/cloudstream.git synced 2024-08-15 01:53:11 +00:00

Add initial selectAll methods

This commit is contained in:
Luna712 2024-07-07 13:37:17 -06:00 committed by GitHub
parent ab7235f43b
commit e69aaf9749
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions
app/src/main/java/com/lagradost/cloudstream3/ui/download

View file

@ -330,6 +330,16 @@ class DownloadAdapter(
}
}
fun selectAllItems() {
currentList.forEachIndexed { index, item ->
val id = item.data.id
if (selectedIds[id] == true) return@forEachIndexed
selectedIds[id] = true
notifyItemChanged(index)
}
}
private fun toggleIsChecked(checkbox: CheckBox, id: Int, name: String) {
val isChecked = !checkbox.isChecked
checkbox.isChecked = isChecked

View file

@ -57,6 +57,16 @@ class DownloadViewModel : ViewModel() {
}
}
fun selectAllItems() {
val currentSelected = selectedIds.value ?: HashMap()
val items = headerCards.value ?: return
items.forEach { item ->
if (currentSelected.containsKey(item.data.id)) return@forEach
currentSelected[item.data.id] = item.data.name
}
_selectedIds.postValue(currentSelected)
}
fun clearSelectedIds() {
_selectedIds.postValue(HashMap())
}