mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 01:34:16 +01:00
Move all DownloadService.stop calls to Downloader (#9146)
Downloader.stop is now the sole responsible for stopping the DownloadService. This will help cleanly removing DownloadService.stop when migrating to coroutines.
This commit is contained in:
parent
4efca04765
commit
0505906e7a
2 changed files with 11 additions and 7 deletions
|
@ -67,7 +67,7 @@ class DownloadManager(
|
||||||
*/
|
*/
|
||||||
fun pauseDownloads() {
|
fun pauseDownloads() {
|
||||||
downloader.pause()
|
downloader.pause()
|
||||||
DownloadService.stop(context)
|
downloader.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +75,7 @@ class DownloadManager(
|
||||||
*/
|
*/
|
||||||
fun clearQueue() {
|
fun clearQueue() {
|
||||||
downloader.clearQueue()
|
downloader.clearQueue()
|
||||||
DownloadService.stop(context)
|
downloader.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,8 +115,8 @@ class DownloadManager(
|
||||||
val wasRunning = downloader.isRunning
|
val wasRunning = downloader.isRunning
|
||||||
|
|
||||||
if (downloads.isEmpty()) {
|
if (downloads.isEmpty()) {
|
||||||
DownloadService.stop(context)
|
downloader.clearQueue()
|
||||||
queue.clear()
|
downloader.stop()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,6 @@ class DownloadManager(
|
||||||
|
|
||||||
if (wasRunning) {
|
if (wasRunning) {
|
||||||
if (queue.isEmpty()) {
|
if (queue.isEmpty()) {
|
||||||
DownloadService.stop(context)
|
|
||||||
downloader.stop()
|
downloader.stop()
|
||||||
} else if (queue.isNotEmpty()) {
|
} else if (queue.isNotEmpty()) {
|
||||||
downloader.start()
|
downloader.start()
|
||||||
|
|
|
@ -167,6 +167,11 @@ class Downloader(
|
||||||
}
|
}
|
||||||
|
|
||||||
isPaused = false
|
isPaused = false
|
||||||
|
|
||||||
|
// Prevent recursion when DownloadService.onDestroy() calls downloader.stop()
|
||||||
|
if (DownloadService.isRunning.value) {
|
||||||
|
DownloadService.stop(context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,9 +222,9 @@ class Downloader(
|
||||||
completeDownload(it)
|
completeDownload(it)
|
||||||
},
|
},
|
||||||
{ error ->
|
{ error ->
|
||||||
DownloadService.stop(context)
|
|
||||||
logcat(LogPriority.ERROR, error)
|
logcat(LogPriority.ERROR, error)
|
||||||
notifier.onError(error.message)
|
notifier.onError(error.message)
|
||||||
|
stop()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -634,7 +639,7 @@ class Downloader(
|
||||||
queue.remove(download)
|
queue.remove(download)
|
||||||
}
|
}
|
||||||
if (areAllDownloadsFinished()) {
|
if (areAllDownloadsFinished()) {
|
||||||
DownloadService.stop(context)
|
stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue