-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GIFs keep playing after switching to other Fragment in a ViewPager #1028
Comments
ViewPager keeps off-screen Fragments in memory in case you go back to them, you can |
Thanks. |
Loading a just-used/cleared resource should be immediate (from memory cache), and the clear-load pattern works with any type of image, not just GIFs. If you really want to start/stop: |
I did't get your start/stop suggestion. Could you please elaborate? |
Drawable drawable = imageView.getDrawable();
if (drawable instanceof Animatable) {
Animatable gif = (Animatable)drawable;
if (gif.isRunning()) gif.stop() else gif.start();
} |
Got it. Thanks. |
I have a ViewPager with 3 fragments. Fragment1 has a RecyclerView that plays GIFs. The problem is when I switch to Fragment 2, GIFs in Fragment1 keep playing. Is there way to stop these GIFs from playing? I want to stop them because when a GIF plays, it consumes ~40% CPU [https://github.com//issues/1029] which ends up in lots of battery drainage even if user is not viewing Fragment1.
The text was updated successfully, but these errors were encountered: