mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Improved the resuming of downloads.
This commit is contained in:
parent
5050e4a92e
commit
9b8abe5ab2
@ -479,7 +479,7 @@ class DownloadManagerMonitor @Inject constructor(
|
|||||||
// due to some reason.
|
// due to some reason.
|
||||||
Error.PAUSED_UNKNOWN,
|
Error.PAUSED_UNKNOWN,
|
||||||
Error.WAITING_TO_RETRY -> {
|
Error.WAITING_TO_RETRY -> {
|
||||||
resumeDownload(downloadRoomEntity.downloadId)
|
resumeDownload(downloadRoomEntity.downloadId, shouldUpdateStatus = false)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ class DownloadManagerMonitor @Inject constructor(
|
|||||||
* @return `true` to update the status and attempt to resume the download.
|
* @return `true` to update the status and attempt to resume the download.
|
||||||
*/
|
*/
|
||||||
private fun handleRetryablePausedDownload(downloadRoomEntity: DownloadRoomEntity): Boolean {
|
private fun handleRetryablePausedDownload(downloadRoomEntity: DownloadRoomEntity): Boolean {
|
||||||
resumeDownload(downloadRoomEntity.downloadId)
|
resumeDownload(downloadRoomEntity.downloadId, shouldUpdateStatus = false)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +519,10 @@ class DownloadManagerMonitor @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resumeDownload(downloadId: Long) {
|
fun resumeDownload(
|
||||||
|
downloadId: Long,
|
||||||
|
shouldUpdateStatus: Boolean = true
|
||||||
|
) {
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
updater.onNext {
|
updater.onNext {
|
||||||
if (pauseResumeDownloadInDownloadManagerContentResolver(
|
if (pauseResumeDownloadInDownloadManagerContentResolver(
|
||||||
@ -528,8 +531,10 @@ class DownloadManagerMonitor @Inject constructor(
|
|||||||
STATUS_RUNNING
|
STATUS_RUNNING
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// pass false when user resumed the download to proceed with further checks.
|
if (shouldUpdateStatus) {
|
||||||
updateDownloadStatus(downloadId, Status.QUEUED, Error.NONE, pausedByUser = false)
|
// pass false when user resumed the download to proceed with further checks.
|
||||||
|
updateDownloadStatus(downloadId, Status.QUEUED, Error.NONE, pausedByUser = false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user