mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Unset downloadDeleteEvent if we are multi-deleting so we don't end up running update on the lists for every single download
This commit is contained in:
parent
821f6e3186
commit
ca59982d60
3 changed files with 26 additions and 6 deletions
|
@ -371,10 +371,10 @@ class DownloadAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleIsChecked(checkbox: CheckBox, id: Int) {
|
private fun toggleIsChecked(checkbox: CheckBox, itemId: Int) {
|
||||||
val isChecked = !checkbox.isChecked
|
val isChecked = !checkbox.isChecked
|
||||||
checkbox.isChecked = isChecked
|
checkbox.isChecked = isChecked
|
||||||
onItemSelectionChanged.invoke(id, isChecked)
|
onItemSelectionChanged.invoke(itemId, isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
class DiffCallback : DiffUtil.ItemCallback<VisualDownloadCached>() {
|
class DiffCallback : DiffUtil.ItemCallback<VisualDownloadCached>() {
|
||||||
|
|
|
@ -38,8 +38,7 @@ class DownloadChildFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent -= it }
|
unsetDownloadDeleteListener()
|
||||||
downloadDeleteEventListener = null
|
|
||||||
detachBackPressedCallback()
|
detachBackPressedCallback()
|
||||||
binding = null
|
binding = null
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
|
@ -171,6 +170,10 @@ class DownloadChildFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
binding?.btnDelete?.setOnClickListener {
|
binding?.btnDelete?.setOnClickListener {
|
||||||
|
// We want to unset it here if we have it so
|
||||||
|
// that we don't have to run it for every download,
|
||||||
|
// we just do it once here.
|
||||||
|
unsetDownloadDeleteListener()
|
||||||
context?.let { ctx ->
|
context?.let { ctx ->
|
||||||
downloadsViewModel.handleMultiDelete(ctx) {
|
downloadsViewModel.handleMultiDelete(ctx) {
|
||||||
arguments?.getString("folder")
|
arguments?.getString("folder")
|
||||||
|
@ -214,4 +217,11 @@ class DownloadChildFragment : Fragment() {
|
||||||
}
|
}
|
||||||
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent += it }
|
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent += it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun unsetDownloadDeleteListener() {
|
||||||
|
downloadDeleteEventListener?.let {
|
||||||
|
VideoDownloadManager.downloadDeleteEvent -= it
|
||||||
|
}
|
||||||
|
downloadDeleteEventListener = null
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -68,8 +68,7 @@ class DownloadFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent -= it }
|
unsetDownloadDeleteListener()
|
||||||
downloadDeleteEventListener = null
|
|
||||||
detachBackPressedCallback()
|
detachBackPressedCallback()
|
||||||
binding = null
|
binding = null
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
|
@ -254,6 +253,10 @@ class DownloadFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
binding?.btnDelete?.setOnClickListener {
|
binding?.btnDelete?.setOnClickListener {
|
||||||
|
// We want to unset it here if we have it so
|
||||||
|
// that we don't have to run it for every download,
|
||||||
|
// we just do it once here.
|
||||||
|
unsetDownloadDeleteListener()
|
||||||
context?.let { ctx ->
|
context?.let { ctx ->
|
||||||
downloadsViewModel.handleMultiDelete(ctx) {
|
downloadsViewModel.handleMultiDelete(ctx) {
|
||||||
downloadsViewModel.updateList(ctx)
|
downloadsViewModel.updateList(ctx)
|
||||||
|
@ -297,6 +300,13 @@ class DownloadFragment : Fragment() {
|
||||||
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent += it }
|
downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent += it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun unsetDownloadDeleteListener() {
|
||||||
|
downloadDeleteEventListener?.let {
|
||||||
|
VideoDownloadManager.downloadDeleteEvent -= it
|
||||||
|
}
|
||||||
|
downloadDeleteEventListener = null
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateStorageInfo(
|
private fun updateStorageInfo(
|
||||||
context: Context,
|
context: Context,
|
||||||
bytes: Long,
|
bytes: Long,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue