From 99710b45d1763690911819e2d72cd92a1e8f9789 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 30 Jul 2020 22:22:37 -0400 Subject: [PATCH] Fix download status updates not appearing in chapters list (fixes #3358) --- .../kanade/tachiyomi/data/download/DownloadService.kt | 4 ++-- .../eu/kanade/tachiyomi/data/download/Downloader.kt | 2 -- .../eu/kanade/tachiyomi/ui/manga/MangaController.kt | 10 ++++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt index 0bcb6e613b..07043e56a6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt @@ -176,14 +176,14 @@ class DownloadService : Service() { /** * Releases the wake lock if it's held. */ - fun PowerManager.WakeLock.releaseIfNeeded() { + private fun PowerManager.WakeLock.releaseIfNeeded() { if (isHeld) release() } /** * Acquires the wake lock if it's not held. */ - fun PowerManager.WakeLock.acquireIfNeeded() { + private fun PowerManager.WakeLock.acquireIfNeeded() { if (!isHeld) acquire() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index d87459a619..ef928fdd08 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -231,8 +231,6 @@ class Downloader( val wasEmpty = queue.isEmpty() // Called in background thread, the operation can be slow with SAF. val chaptersWithoutDir = async { - val mangaDir = provider.findMangaDir(manga, source) - chapters // Filter out those already downloaded. .filter { provider.findChapterDir(it, manga, source) == null } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 3695b9578e..bb503ac142 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -49,7 +49,6 @@ import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.offsetAppbarHeight import eu.kanade.tachiyomi.ui.manga.chapter.ChapterDividerItemDecoration -import eu.kanade.tachiyomi.ui.manga.chapter.ChapterHolder import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersAdapter import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersSettingsSheet @@ -685,11 +684,10 @@ class MangaController : } fun onChapterStatusChange(download: Download) { - getHolder(download.chapter)?.notifyStatus(download.status) - } - - private fun getHolder(chapter: Chapter): ChapterHolder? { - return binding.recycler.findViewHolderForItemId(chapter.id!!) as? ChapterHolder + chaptersAdapter?.currentItems?.find { it.id == download.chapter.id }?.let { + chaptersAdapter?.updateItem(it) + chaptersAdapter?.notifyDataSetChanged() + } } fun openChapter(chapter: Chapter, hasAnimation: Boolean = false) {