Glimpse: Specify size of the image to load

It allows Coil to avoid caching the whole image for reel viewing

Change-Id: I0994848364aea8592325570b8dcfd6fe9efd713b
This commit is contained in:
Luca Stefani 2023-08-09 11:51:10 +02:00 committed by Sebastiano Barezzi
parent 2bfdb7abb3
commit de55efce60
No known key found for this signature in database
GPG Key ID: 763BD3AE91A7A13F
3 changed files with 5 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import androidx.navigation.NavController
import androidx.recyclerview.widget.RecyclerView
import coil.load
import org.lineageos.glimpse.R
import org.lineageos.glimpse.ext.*
import org.lineageos.glimpse.fragments.AlbumFragment
import org.lineageos.glimpse.models.Album
@ -75,6 +76,7 @@ class AlbumThumbnailAdapter(
)
thumbnailImageView.load(album.thumbnail) {
size(ThumbnailLayoutManager.MAX_THUMBNAIL_SIZE.px)
placeholder(R.drawable.thumbnail_placeholder)
}

View File

@ -17,6 +17,7 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import coil.load
import org.lineageos.glimpse.R
import org.lineageos.glimpse.ext.*
import org.lineageos.glimpse.models.Media
import org.lineageos.glimpse.models.MediaType
import java.time.ZoneId
@ -192,6 +193,7 @@ class ThumbnailAdapter(
this.position = position
thumbnailImageView.load(media.externalContentUri) {
size(ThumbnailLayoutManager.MAX_THUMBNAIL_SIZE.px)
placeholder(R.drawable.thumbnail_placeholder)
}
videoOverlayImageView.isVisible = media.mediaType == MediaType.VIDEO

View File

@ -43,7 +43,7 @@ class ThumbnailLayoutManager(
/**
* Maximum thumbnail size, useful for high density screens.
*/
private const val MAX_THUMBNAIL_SIZE = 128
const val MAX_THUMBNAIL_SIZE = 128
private enum class Orientation {
VERTICAL,