Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 567
Cristian Holdunu Avatar asked Aug 11 '18 07:08

Cristian Holdunu


People also ask

Are GIFs copyrighted?

Yes, like any original creative work GIFS are subject to copyright.

What is the difference between GIF and animated GIF?

Animated GIF is an extension of the GIF standard, which allows animated images to be created by cramming a set of frames into a single file for sequential playback. Even with multiple images on the same file, the file size can still be made small because of the way GIF is encoded and because of a limited color palette.

Is GIF lossy or lossless?

Because GIF is a lossless data compression format, meaning that no information is lost in the compression, it quickly became a popular format for transmitting and storing graphic files.


1 Answers

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

like image 199
Cristian Holdunu Avatar answered Sep 29 '22 03:09

Cristian Holdunu