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:
parent
ab7235f43b
commit
e69aaf9749
2 changed files with 20 additions and 0 deletions
|
@ -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) {
|
private fun toggleIsChecked(checkbox: CheckBox, id: Int, name: String) {
|
||||||
val isChecked = !checkbox.isChecked
|
val isChecked = !checkbox.isChecked
|
||||||
checkbox.isChecked = isChecked
|
checkbox.isChecked = isChecked
|
||||||
|
|
|
@ -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() {
|
fun clearSelectedIds() {
|
||||||
_selectedIds.postValue(HashMap())
|
_selectedIds.postValue(HashMap())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue