question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error icons will re-appear on RecyclerView items even when request is cleared

See original GitHub issue

Describe 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:

https://user-images.githubusercontent.com/65370175/141704623-cc56c3ec-44af-4078-b2cb-3d3f904a76fd.mp4

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:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
OxygenCobaltcommented, Nov 20, 2021

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.

0reactions
colinrtwhitecommented, Nov 20, 2021

Thanks for looking into this 🙏.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recyclerview Item Removes and Reappears Immediately ...
I am trying to delete a list from recycler view. Problem is when I delete the item, It removes from ...
Read more >
RecyclerView
List mutation with SortedList If your RecyclerView receives updates incrementally, e.g. item X is inserted, or item Y is removed, you can use...
Read more >
Top 10 Most Common Mistakes That Android Developers ...
An Android beginner or an old pro? Avoid these common mistakes and become a better Android programmer today.
Read more >
Update recycler view content without refreshing the data.
Let's create a progress indicator for our items. We will need to change the indicator icon and update the progress bar with a...
Read more >
Android RecyclerView Load More, Endless Scrolling
In order to show the loading icon view at the bottom of the RecyclerView, we need to first add a NULL element to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found