Skip to content

Commit

Permalink
Fixed #67 and #69
Browse files Browse the repository at this point in the history
  • Loading branch information
Jays2Kings committed Jan 28, 2020
1 parent 5ea683b commit c745ac7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/download_queue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down

0 comments on commit c745ac7

Please sign in to comment.