Glimpse: Specify the memory key for images loaded via Coil

If the Uri matches but sizes don't Coil will re-fetch the image
from disk, that's not optimal.

Change-Id: I2336b851f2b11819845f4bd5815d1ec60b7fccd4
This commit is contained in:
Luca Stefani 2023-08-09 23:38:39 +02:00 committed by Sebastiano Barezzi
parent c45a4cb57b
commit a528b7302b
No known key found for this signature in database
GPG Key ID: 763BD3AE91A7A13F
3 changed files with 5 additions and 1 deletions

View File

@ -71,6 +71,7 @@ class AlbumThumbnailAdapter(
)
thumbnailImageView.load(album.thumbnail.externalContentUri) {
memoryCacheKey("thumbnail_${album.thumbnail.id}")
size(ThumbnailLayoutManager.MAX_THUMBNAIL_SIZE.px)
placeholder(R.drawable.thumbnail_placeholder)
}

View File

@ -93,7 +93,9 @@ class MediaViewerAdapter(
fun bind(media: Media, position: Int) {
this.media = media
this.position = position
imageView.load(media.externalContentUri)
imageView.load(media.externalContentUri) {
memoryCacheKey("full_${media.id}")
}
}
fun onViewAttachedToWindow() {

View File

@ -150,6 +150,7 @@ class ThumbnailAdapter(
this.position = position
thumbnailImageView.load(media.externalContentUri) {
memoryCacheKey("thumbnail_${media.id}")
size(ThumbnailLayoutManager.MAX_THUMBNAIL_SIZE.px)
placeholder(R.drawable.thumbnail_placeholder)
}