Error icons will re-appear on RecyclerView items even when request is cleared
See original GitHub issueDescribe the bug
I have a RecyclerView
where each ViewHolder
requests an image. I noticed that if a ViewHolder
launches a longer request is that ends up erroring while a new image is loaded into the same ViewHolder
, that error icon will overwrite the image that was loaded. I’ve attached an example below:
Is this a bug or is my implementation flawed? I’ve already tried cancelling requests with ImageView.clear
before I load new images but that doesn’t seem to do anything. It seems like the request that errors out is already completed by the time I load the new image.
To Reproduce
I configured my ImageLoader
with the following:
ImageLoader.Builder(applicationContext)
.diskCachePolicy(CachePolicy.DISABLED) // Not downloading anything, so no disk-caching
.crossfade(true)
.placeholder(android.R.color.transparent)
.build()
Whenever a ViewHolder
is bound with new data, I make a request like this:
binding.itemImage,clear() // Clear previous requests
Coil.imageLoader(context).enqueue(
ImageRequest.Builder(context)
.target(binding.itemImage) // Just an ImageView
.data(song) // We load album art either through MediaMetadataRetriever or a MediaStore URI
.fetcher(AlbumArtFetcher(context)) // This fetcher can take awhile and often errors out, hence the issue
.error(R.drawable.ic_album) // The error icon in particular
.build()
)
I’m only detailing the coil implementation for simplicity. If you need to see more then let me know.
Version All API levels, coil 1.4.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
I tried out 2.0.0 and it seems to fix this issue [probably because of the new cache implementation]. I don’t think this is relevant any more.
Thanks for looking into this 🙏.