Fixed logic on fetching cached images in manga details

This commit is contained in:
Jay 2020-05-10 15:30:32 -04:00
parent f046f12311
commit 821f068728
2 changed files with 11 additions and 2 deletions

View File

@ -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 {

View File

@ -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()