From 821f06872808d0b95a7e2615fab7bd54093a027c Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 10 May 2020 15:30:32 -0400 Subject: [PATCH] Fixed logic on fetching cached images in manga details --- .../tachiyomi/ui/manga/MangaDetailsPresenter.kt | 2 +- .../eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index fbe601e08a..a034c41638 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -53,7 +53,7 @@ class MangaDetailsPresenter( val manga: Manga, val source: Source, val preferences: PreferencesHelper = Injekt.get(), - private val coverCache: CoverCache = Injekt.get(), + val coverCache: CoverCache = Injekt.get(), private val db: DatabaseHelper = Injekt.get(), private val downloadManager: DownloadManager = Injekt.get() ) : DownloadQueue.DownloadListener, LibraryServiceListener { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index 416a26bdf2..d8e2feb1a7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -308,7 +308,7 @@ class MangaHeaderHolder( } fun updateCover(manga: Manga, force: Boolean = false) { - if (!manga.initialized || (adapter.delegate.coverColor() == null && manga.favorite && !force)) return + if (!isCached(manga)) return GlideApp.with(view.context).load(manga).diskCacheStrategy(DiskCacheStrategy.RESOURCE) .signature(ObjectKey(MangaImpl.getLastCoverFetch(manga.id!!).toString())) .into(manga_cover) @@ -317,6 +317,15 @@ class MangaHeaderHolder( .transition(DrawableTransitionOptions.withCrossFade()).into(backdrop) } + private fun isCached(manga: Manga): Boolean { + val coverCache = adapter.delegate.mangaPresenter().coverCache + manga.thumbnail_url?.let { + return if (manga.favorite) coverCache.getCoverFile(it).exists() + else true + } + return manga.initialized + } + fun expand() { sub_item_group.visible() if (!showMoreButton) more_button_group.gone()