Search code examples
android-recyclerviewgiffresco

Gif blinking in RecyclerView using Fresco


I use Fresco to load gif in a Recyclerview.

Here is my kotlin code:

fun loadResizeImage(uri: Uri, view: SimpleDraweeView, width: Int, height: Int) {
    val request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setResizeOptions(ResizeOptions(width, height)).build()

val controller = Fresco.newDraweeControllerBuilder()
        .setOldController(view.controller)
        .setImageRequest(request)
        .build()
view.controller = controller

I don't play the gif, I just load it as a static image. But when I invoke notifydatasetchanged, the gif blinks. I have set the supportsChangeAnimations to false, and only the gif is blinking. Can anyone help me?


Solution

  • My solution is to set tag to the view, if the tag equals to the uri i won't reload the image. But I find when i invoke notifyDataSetChange, the tag i set to the view is changed.but when I invoke notifyItemChanged,it doesn't.I have no idea why the tag changed(i didn't scroll the RecyclerView).