Skip to content
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

How to manually play animation again when returned from back stack #1841

Closed
darek607 opened this issue Jul 12, 2021 · 3 comments · Fixed by #2002
Closed

How to manually play animation again when returned from back stack #1841

darek607 opened this issue Jul 12, 2021 · 3 comments · Fixed by #2002

Comments

@darek607
Copy link

darek607 commented Jul 12, 2021

Thanks for this library!

I encountered a strange bug and spent quite much time to ivestigate the issue. I wanted to play animation manually every time fragment view is loaded (onViewCreated).

Steps:

  1. Inside onViewCreated of Fragment A, set progress to 0 and call playAnimation
  2. Navigate to Fragment B with back stack entry and press back in order to return to the A

Expected result:
The animation should play again.

Result: The animation usually don't animate again after navigating back to fragment A. It shows a fully loaded anim immediately.

Tested on 3.7.1 and 3.2.2 versions.

@darek607 darek607 changed the title Documnetation for addLottieOnCompositionLoadedListener Documentation for addLottieOnCompositionLoadedListener Jul 12, 2021
@darek607 darek607 changed the title Documentation for addLottieOnCompositionLoadedListener How to manually play animation again when returned from back stack Jul 13, 2021
@darek607
Copy link
Author

darek607 commented Jul 13, 2021

It seems that lottie view incorrectly handles the saved state. The issue is gone after adding
android:saveEnabled="false" for the LottieAnimationView.

Previously I though that adding addLottieOnCompositionLoadedListener solves the issue, but it solves it only partially - the bug still sometimes happened (in about 1 per 10 Fragment loads).

@gpeal
Copy link
Collaborator

gpeal commented Sep 10, 2021

@darek607 Can you attach a sample project that reproduces this?

@darek607
Copy link
Author

@gpeal I've created a basic sample demonstrating the issue: https://github.com/darek607/Lottie-Android-Bug

  1. Run the app (animation should play successfully)
  2. Click NEXT button to launch another fragment
  3. Go back to animation fragment (anim won't play again, but it should)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants