mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Remove messy, and now-unneeded methods
This commit is contained in:
parent
4b1d56b893
commit
e5be3e1866
3 changed files with 0 additions and 49 deletions
app/src/main/java/com/lagradost/cloudstream3/ui/download
|
@ -298,15 +298,6 @@ class DownloadAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
fun updateSelectedItems(updatedList: List<VisualDownloadCached>) {
|
||||
updatedList.forEach { item ->
|
||||
val position = currentList.indexOfFirst { it.data.id == item.data.id }
|
||||
if (position != -1) {
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DiffCallback : DiffUtil.ItemCallback<VisualDownloadCached>() {
|
||||
override fun areItemsTheSame(oldItem: VisualDownloadCached, newItem: VisualDownloadCached): Boolean {
|
||||
return oldItem.data.id == newItem.data.id
|
||||
|
|
|
@ -112,7 +112,6 @@ class DownloadFragment : Fragment() {
|
|||
}
|
||||
observe(downloadsViewModel.selectedIds) {
|
||||
handleSelectedChange(it)
|
||||
updateSelectedState(it)
|
||||
binding?.downloadDeleteToolbar?.btnDelete?.text =
|
||||
getString(R.string.delete_count).format(it.count())
|
||||
}
|
||||
|
@ -217,35 +216,6 @@ class DownloadFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateSelectedState(selected: HashMap<Int, String>) {
|
||||
if (selected == downloadsViewModel.selectedIds.value) return
|
||||
val currentSelectedIds = downloadsViewModel.selectedIds.value ?: HashMap()
|
||||
|
||||
// Remove deselected items
|
||||
currentSelectedIds.keys.retainAll(selected.keys)
|
||||
|
||||
// Add newly selected items
|
||||
selected.forEach { (id, name) ->
|
||||
currentSelectedIds[id] = name
|
||||
}
|
||||
|
||||
downloadsViewModel.setSelected(currentSelectedIds)
|
||||
|
||||
val currentList = downloadsViewModel.headerCards.value ?: return
|
||||
val updatedList = currentList.map { item ->
|
||||
item.copy(selected = currentSelectedIds.containsKey(item.data.id))
|
||||
}
|
||||
|
||||
val adapter = binding?.downloadList?.adapter as? DownloadAdapter
|
||||
|
||||
// Pass the IDs of the updated list to the ViewModel for filtering
|
||||
val updatedIds = updatedList.filter { it.selected }.map { it.data.id }.toSet()
|
||||
downloadsViewModel.filterSelectedIds(updatedIds)
|
||||
|
||||
val selectedItems = updatedList.filter { it.selected }
|
||||
adapter?.updateSelectedItems(selectedItems)
|
||||
}
|
||||
|
||||
private fun setUpDownloadDeleteListener() {
|
||||
downloadDeleteEventListener = { id ->
|
||||
val list = (binding?.downloadList?.adapter as? DownloadAdapter)?.currentList
|
||||
|
|
|
@ -50,10 +50,6 @@ class DownloadViewModel : ViewModel() {
|
|||
_selectedIds.postValue(currentSelected)
|
||||
}
|
||||
|
||||
fun setSelected(selected: HashMap<Int, String>) {
|
||||
_selectedIds.postValue(selected)
|
||||
}
|
||||
|
||||
fun removeSelected(id: Int) {
|
||||
selectedIds.value?.let { selectedIds ->
|
||||
selectedIds.remove(id)
|
||||
|
@ -61,12 +57,6 @@ class DownloadViewModel : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
fun filterSelectedIds(updatedIds: Set<Int>) {
|
||||
val currentSelectedIds = selectedIds.value ?: return
|
||||
val filteredIds = currentSelectedIds.filterKeys { updatedIds.contains(it) }
|
||||
_selectedIds.postValue(HashMap(filteredIds))
|
||||
}
|
||||
|
||||
fun clearSelectedIds() {
|
||||
_selectedIds.postValue(HashMap())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue