Delete from the download queue on the main thread. It could fix some crashes

This commit is contained in:
len 2016-05-05 16:05:36 +02:00
parent 1226023dc2
commit 0de214c3b5

View File

@ -57,6 +57,12 @@ class DownloadManager(private val context: Context, private val sourceManager: S
.lift(DynamicConcurrentMergeOperator<Download, Download>({ downloadChapter(it) }, threadsSubject)) .lift(DynamicConcurrentMergeOperator<Download, Download>({ downloadChapter(it) }, threadsSubject))
.onBackpressureBuffer() .onBackpressureBuffer()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doOnNext {
// Delete successful downloads from queue
if (it.status == Download.DOWNLOADED) {
queue.del(it)
}
}
.map { download -> areAllDownloadsFinished() } .map { download -> areAllDownloadsFinished() }
.subscribe({ finished -> .subscribe({ finished ->
if (finished!!) { if (finished!!) {
@ -302,10 +308,6 @@ class DownloadManager(private val context: Context, private val sourceManager: S
} }
download.totalProgress = actualProgress download.totalProgress = actualProgress
download.status = status download.status = status
// Delete successful downloads from queue after notifying
if (status == Download.DOWNLOADED) {
queue.del(download)
}
} }
// Return the page list from the chapter's directory if it exists, null otherwise // Return the page list from the chapter's directory if it exists, null otherwise