Open mradlmaier opened 11 months ago
Not sure if you're still looking for an answer to this, but I started playing with Glide today and had the same question.
The docs say to call it.thumbnail passing in a requestManager - but how do we get one when we don't have a fragment? It turns out you had the answer above - Glide.with(context).
So tweaking your example, I have the following:
@Composable
fun GlideImagePage(name: String, description: String, imageRes: Int, imageUrl: String, thumbnailUrl : String) {
val context = LocalContext.current
GlideImage(
model = imageUrl,
contentDescription = description,
modifier = Modifier
.padding(1.dp),
contentScale = ContentScale.FillWidth
){
it.thumbnail(Glide.with(context).asDrawable().load(thumbnailUrl))
}
}
This seems to work for me, I tested by using https://sample-videos.com/img/Sample-jpg-image-50kb.jpg and https://sample-videos.com/img/Sample-jpg-image-30mb.jpg.
I loading images into a LazyColumn, and while the full-size image is loading, a much smaller thumbnail image shall and be replaced by the full-sized image.
Based on the documentation, my code looks like this:
This code seems to be working, but i fear that there will be 3 requests created, one for the thumbnail image, one for the full-size image by the code in the inner braces, and before that, another request for the full-size image in the GlideImage Tag, Is this the case and if so, what happens to the full-size image request? Will it leak?
Can somebody enlighten me?
Thanks!