Search code examples
androidimagefresco

Playing animated images with RetainingDataSourceSupplier


I'm using fresco to display gifs in a RecyclerView. After the user has tapped an imaged I open a details screen where I should display in the end a high-resolution GIF.

If I just load another GIF in the same DraweeView the content will disappear as this is the way Fresco works and the user will see a black image while the high res one loads, although I already have a low quality preview available.

I also tried using the low-res/high-res scheme, but while the high res image is loading, the low-res is not animated.

Later I discovered the RetainingDataSourceSupplier in Fresco, which works by keeping the current image in a DraweeView until a new one is loaded. This works fine but it doesn't seem to work for animated content.

Can you help me retain the current animated content until the high quality one is downloaded?


Solution

  • I ended up rewriting some parts of fresco. Basically, RetainingDataSource was hacking the implementation of the DataSource, keeping it's state in PROGRESS, forever. That means the controllers will never get notified when a new resource is placed into the DataSource and they will never be able to play GIFs.

    I managed the problem by modifying the fresco lib code and notified controller after each loaded resource. I've made a PR to fresco, maybe they will agree with the changes as I consider the RetainingDataSource to be incomplete.

    You can check the PR here:

    Proper support for GIFs when using a RetainingDataSource