Fixed cover being fetched multiple times on update
Should fix bad caching of images as well
This commit is contained in:
parent
e20ea71403
commit
927700f4e2
4 changed files with 19 additions and 9 deletions
|
@ -81,7 +81,7 @@ class LibraryGridHolder(
|
||||||
private fun setCover(manga: Manga, id: Long) {
|
private fun setCover(manga: Manga, id: Long) {
|
||||||
if ((adapter.recyclerView.context as? Activity)?.isDestroyed == true) return
|
if ((adapter.recyclerView.context as? Activity)?.isDestroyed == true) return
|
||||||
GlideApp.with(adapter.recyclerView.context).load(manga)
|
GlideApp.with(adapter.recyclerView.context).load(manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString()))
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString()))
|
||||||
.apply {
|
.apply {
|
||||||
if (fixedSize) centerCrop()
|
if (fixedSize) centerCrop()
|
||||||
|
|
|
@ -368,8 +368,9 @@ class MangaDetailsController : BaseController,
|
||||||
/** Get the color of the manga cover based on the current theme */
|
/** Get the color of the manga cover based on the current theme */
|
||||||
fun setPaletteColor() {
|
fun setPaletteColor() {
|
||||||
val view = view ?: return
|
val view = view ?: return
|
||||||
|
coverColor = null
|
||||||
GlideApp.with(view.context).load(manga)
|
GlideApp.with(view.context).load(manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(manga!!.id!!).toString()))
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(manga!!.id!!).toString()))
|
||||||
.into(object : CustomTarget<Drawable>() {
|
.into(object : CustomTarget<Drawable>() {
|
||||||
override fun onResourceReady(
|
override fun onResourceReady(
|
||||||
|
@ -390,6 +391,7 @@ class MangaDetailsController : BaseController,
|
||||||
}
|
}
|
||||||
coverColor = backDropColor
|
coverColor = backDropColor
|
||||||
getHeader()?.setBackDrop(backDropColor)
|
getHeader()?.setBackDrop(backDropColor)
|
||||||
|
getHeader()?.updateCover(presenter.manga, resource)
|
||||||
if (toolbarIsColored) {
|
if (toolbarIsColored) {
|
||||||
val translucentColor = ColorUtils.setAlphaComponent(backDropColor, 175)
|
val translucentColor = ColorUtils.setAlphaComponent(backDropColor, 175)
|
||||||
(activity as MainActivity).toolbar.setBackgroundColor(translucentColor)
|
(activity as MainActivity).toolbar.setBackgroundColor(translucentColor)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -255,12 +256,7 @@ class MangaHeaderHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!manga.initialized) return
|
if (!manga.initialized) return
|
||||||
GlideApp.with(view.context).load(manga).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
updateCover(manga)
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(manga.id!!).toString()))
|
|
||||||
.into(manga_cover)
|
|
||||||
GlideApp.with(view.context).load(manga).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(manga.id!!).toString())).centerCrop()
|
|
||||||
.transition(DrawableTransitionOptions.withCrossFade()).into(backdrop)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MaterialButton.checked(checked: Boolean) {
|
private fun MaterialButton.checked(checked: Boolean) {
|
||||||
|
@ -312,6 +308,18 @@ class MangaHeaderHolder(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateCover(manga: Manga, cover: Drawable? = null) {
|
||||||
|
if (adapter.delegate.coverColor() == null) return
|
||||||
|
GlideApp.with(view.context).load(cover ?: manga)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(manga.id!!).toString()))
|
||||||
|
.into(manga_cover)
|
||||||
|
GlideApp.with(view.context).load(cover ?: manga)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(manga.id!!).toString())).centerCrop()
|
||||||
|
.transition(DrawableTransitionOptions.withCrossFade()).into(backdrop)
|
||||||
|
}
|
||||||
|
|
||||||
fun expand() {
|
fun expand() {
|
||||||
sub_item_group.visible()
|
sub_item_group.visible()
|
||||||
if (!showMoreButton) more_button_group.gone()
|
if (!showMoreButton) more_button_group.gone()
|
||||||
|
|
|
@ -71,7 +71,7 @@ class RecentMangaHolder(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
GlideApp.with(itemView.context).load(item.mch.manga).diskCacheStrategy(DiskCacheStrategy
|
GlideApp.with(itemView.context).load(item.mch.manga).diskCacheStrategy(DiskCacheStrategy
|
||||||
.AUTOMATIC)
|
.RESOURCE)
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(item.mch.manga.id!!).toString())).into(cover_thumbnail)
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(item.mch.manga.id!!).toString())).into(cover_thumbnail)
|
||||||
notifyStatus(
|
notifyStatus(
|
||||||
if (adapter.isSelected(adapterPosition)) Download.CHECKED else item.status,
|
if (adapter.isSelected(adapterPosition)) Download.CHECKED else item.status,
|
||||||
|
|
Reference in a new issue