[Question] How to prevent clearing an ImageView before the load is complete?
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
**Glide Version**: 4.2.0
**Integration libraries**: none
**Issue details**: I have an `ImageView` that needs to be refreshed often, but each time there is a change the image **flickers** white (unless it is present in the memory cache).
This must be the default behavior, as I can see in the basic lifecycle of a `Glide` request:
1. Cancel any in progress load for the View and/or **clear out any current image** and recycle its resource.
2. Set the placeholder drawable
3. Start the image load
4. If it completes synchronously (from the memory cache) set the image on the View and do not animate.
5. If it completes asynchronously, set the image on the View and animate.
Is there a way to **disable the default clearing** of the `ImageView` on step 1) **until the next image is loaded** in order to prevent the flicker?
The following works, but I was wondering if there is a simpler solution, for example by disabling animations. I read something about a `dontAnimate()` method but can't find it on `4.2.0`.
```kotlin
Glide
.with(thisActivity)
.asBitmap()
.load(someUrl)
.into(object : SimpleTarget() {
override fun onResourceReady(resource: Bitmap, transition: Transition) {
imageView.setImageBitmap(resource)
}
})
```
Contributor guide
Research direction
Start with the Glide 4.2.0 request lifecycle described in the issue, especially cancellation, clearing, placeholder handling, and the mentioned dontAnimate option. Determine whether the requested behavior can use an existing ImageView target or transition entry point; done means refreshing the view without clearing or flickering before the replacement image is ready.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100