glide icon indicating copy to clipboard operation
glide copied to clipboard

Compose Bugfix: When requestBuilder not changed, GlideImage reset to display nothing or loadingPainter

Open hehua2008 opened this issue 1 year ago • 1 comments

Compose Bugfix: If requestBuilder has not changed, the requestState, painter(State) and requestListener should not change either. Otherwise, the GlideImage will display nothing or loadingPainter. Since requestState will be reset to RequestState.Loading and GlideNode.launchRequest will not run due to requestBuilder not changed.

This may happen when the request model has not changed but the requestBuilderTransform has changed, and the change of requestBuilderTransform has not been detected in RequestBuilder.equals(). So requestBuilder is considered to have no change.

e.g:

    val transform1: RequestBuilderTransform<Drawable> = {
        val unused = "transform1"
        it
    }

    val transform2: RequestBuilderTransform<Drawable> = {
        val unused = "transform2"
        it
    }

    val switch = Random.nextBoolean()

    GlideImage(
        model = url,
        contentDescription = url,
        loading = placeholder(loadingPainter),
        modifier = modifier
            .fillMaxWidth()
            .aspectRatio(1f),
        requestBuilderTransform = if (switch) transform1 else transform2
    )

hehua2008 avatar Apr 01 '24 03:04 hehua2008

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Apr 01 '24 03:04 google-cla[bot]

Give up struggling with glide compose and turn to coil which supports compose on multiple platforms💔

hehua2008 avatar May 14 '24 12:05 hehua2008