This commit is contained in:
Jay 2020-01-27 21:09:25 -08:00
parent 5ea683b686
commit c745ac7350
4 changed files with 18 additions and 2 deletions

View File

@ -203,6 +203,20 @@ class DownloadManager(val context: Context) {
* @param source the source of the chapters.
*/
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source) {
val wasPaused = isPaused()
if (chapters.isEmpty()) {
DownloadService.stop(context)
downloader.queue.clear()
return
}
downloader.pause()
downloader.queue.remove(chapters)
if(!wasPaused && downloader.queue.isNotEmpty()){
downloader.start()
}
else if (downloader.queue.isEmpty()) {
DownloadService.stop(context)
}
queue.remove(chapters)
val chapterDirs = provider.findChapterDirs(chapters, manga, source) + provider.findTempChapterDirs(chapters, manga, source)
chapterDirs.forEach { it.delete() }

View File

@ -112,6 +112,7 @@ internal class DownloadNotifier(private val context: Context) {
setContentTitle("$title - $chapter".chop(30))
setContentText(context.getString(R.string.chapter_downloading_progress)
.format(download.downloadedImages, download.pages!!.size))
setStyle(null)
setProgress(download.pages!!.size, download.downloadedImages, false)
}
// Displays the progress bar on notification

View File

@ -128,7 +128,8 @@ class Downloader(
} else {
if (notifier.paused) {
notifier.paused = false
notifier.onDownloadPaused()
if (queue.isEmpty()) notifier.dismiss()
else notifier.onDownloadPaused()
} else if (notifier.isSingleChapter && !notifier.errorThrown) {
notifier.isSingleChapter = false
} else {

View File

@ -14,7 +14,7 @@
android:visible="false"
app:showAsAction="ifRoom"/>
<item android:title="@string/action_clear"
<item android:title="@string/action_cancel_all"
android:id="@+id/clear_queue"
android:visible="false"
app:showAsAction="never"/>