glide
glide copied to clipboard
[Compose] GlideSubcomposition state is changing from Loading-Success-Loading
trafficstars
I'm using the Glide Compose version, and the images were loading fine in the Alpha version. However, after switching to the Beta version, I started encountering this issue.
def glideComposeVersion = '1.0.0-alpha.3' def glideComposeVersion = '1.0.0-beta01'
Older Alpha version code:
val placeholder = placeholder { CustomPlaceHolder(modifier = placeHolderModifier) }
GlideImage(
model = image?.image,
contentDescription = "image",
modifier = imageModifier,
contentScale = ContentScale.Fit,
alignment = Alignment.Center,
colorFilter = null,
alpha = DefaultAlpha,
loading = placeholder,
failure = placeholder
) {
it.diskCacheStrategy(DiskCacheStrategy.ALL)
}](url)
Newer Beta version code:
GlideSubcomposition(
image?.image,
imageModifier,
{ it.diskCacheStrategy(DiskCacheStrategy.ALL) }) {
if (state !is RequestState.Success) {
CustomPlaceHolder(modifier = placeHolderModifier)
} else {
Image(
painter,
contentDescription = "image",
imageModifier,
contentScale = ContentScale.Fit,
alignment = Alignment.Center,
colorFilter = null,
alpha = DefaultAlpha,
)
}
}
Troubleshooting
When I printed state in the Beta version, it first shows loading, then success, and then switches back to loading. As a result, the images on the UI flicker and disappear.