fix(DownloadQueue): Fix ConcurrentModificationException

This commit is contained in:
Ahmad Ansori Palembani 2024-12-03 07:33:03 +07:00
parent b9f7d18d3d
commit ea9407b49d
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -43,7 +43,7 @@ class DownloadQueue(
if (download.status == Download.State.DOWNLOADING || download.status == Download.State.QUEUE) {
download.status = Download.State.NOT_DOWNLOADED
}
downloadListeners.forEach { it.updateDownload(download) }
callListeners(download)
if (removed) {
updatedRelay.call(Unit)
}
@ -73,7 +73,7 @@ class DownloadQueue(
if (download.status == Download.State.DOWNLOADING || download.status == Download.State.QUEUE) {
download.status = Download.State.NOT_DOWNLOADED
}
downloadListeners.forEach { it.updateDownload(download) }
callListeners(download)
}
queue.clear()
store.clear()
@ -102,7 +102,10 @@ class DownloadQueue(
}
private fun callListeners(download: Download) {
downloadListeners.forEach { it.updateDownload(download) }
val iterator = downloadListeners.iterator()
while (iterator.hasNext()) {
iterator.next().updateDownload(download)
}
}
// private fun setPagesSubject(pages: List<Page>?, subject: PublishSubject<Int>?) {