koral--/android-gif-drawable

Problems play gif in several views, on different pages

HighwayLight opened this issue · 2 comments

I want to play one GifDrawable in several ImageViews.
In GifActivityA, I do the following:


public static GifDrawable mGifDrawable = new GifDrawable(path);
public static MultiCallback mMultiCallback = new MultiCallback();

imageViewA1.setImageDrawable(mGifDrawable);
myMultiCallback .addView(imageViewA1);

imageViewA2.setImageDrawable(mGifDrawable);
myMultiCallback .addView(imageViewA2);

gifDrawable.setCallback(myMultiCallback );

Everything is ok!
Then i want to set the drawable(mGifDrawable) to imageViewB in GifActivityB.
I do the following:

imageViewB.setImageDrawable(GifActivity.gif);
GifActivityA.multiCallback.addView(imageViewB);
GifActivityA.gif.setCallback(GifActivity.multiCallback);

Everything is ok!
But, when back to GifActivityA,imageViewA1 and imageViewA2 ,cannot play gif

https://raw.githubusercontent.com/GoogleDo/AppDemo/main/app/Lark20210827-174513.gif

Sorry for the late reply.
You shouldn't access fields of Activities in a static way. Activity instance may be garbage collected when not displayed.

Not sure what problem are you trying to solve?
Why not just 2 independent GIFs on 2 activites?

Closing due to inactivity