Move window/view visibility handling from LottieAnimationView to LottieDrawable (#1981)

Previously, all of the logic to pause/resume Lottie animations on events such as hiding a view, backgrounding an app, etc. were handled by LottieAnimationView. This logic works fine for the default cause. However, LottieDrawable had no notion of visibility handling itself. As a result, if somebody were to use LottieDrawable on its own, they would have to get the lifecycle exactly right or else they could risk leaking animators and impacting the user's battery life.

This PR combines all of the logic into Drawable.setVisible. This also simplifies things because it is a single API vs views that have to deal with window attachment and visibility changes.

I ran all existing FragmentVisibilityTests and they all pass and the intention is to maintain backwards compatibility.
3 files changed
tree: e61810608bb1ed55b6966420f45329c83a5b768b
  1. .github/
  2. .idea/
  3. After Effects Samples/
  4. gifs/
  5. gradle/
  6. images/
  7. issue-repro-compose/
  8. issue-repro/
  9. lottie-compose/
  10. lottie/
  11. sample-compose/
  12. sample/
  13. snapshot-tests/
  14. .gitattributes
  15. .gitignore
  16. CHANGELOG.md
  17. CHANGELOG_COMPOSE.md
  18. CODE_OF_CONDUCT.md
  19. DESIGNER_NOTES.md
  20. LICENSE
  21. README.md
  22. RELEASE.md
  23. build.gradle
  24. credentials.tar.gz
  25. decrypt.sh
  26. deploy_snapshot.sh
  27. gcloud_run.sh
  28. gcloud_setup.sh
  29. gradle.properties
  30. gradlew
  31. gradlew.bat
  32. post_pr_comment.js
  33. secrets.tar.enc
  34. settings.gradle
  35. sign.sh
  36. upload_release.sh
  37. version.sh
README.md

Lottie for Android, iOS, React Native, Web, and Windows

Build Status

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. They say a picture is worth 1,000 words so here are 13,000:

Sponsors

Lottie is maintained and improved on nights and weekends. If you use Lottie in your app, please consider sponsoring it to help ensure that we can continue to improve the project we love. Click the sponsor button above to learn more

Lead Sponsors

View documentation, FAQ, help, examples, and more at airbnb.io/lottie

Example1

Example2

Example3

Community

Example4

Download

Gradle is the only supported build configuration, so just add the dependency to your project build.gradle file:

dependencies {
  implementation 'com.airbnb.android:lottie:$lottieVersion'
}

The latest Lottie version is: lottieVersion

The latest stable Lottie-Compose version is: lottieVersion Click here for more information on Lottie-Compose.

Lottie 2.8.0 and above only supports projects that have been migrated to androidx. For more information, read Google's migration guide.

Contributing

Because development has started for Lottie Compose, Gradle, and the Android Gradle Plugin will be kept up to date with the latest canaries. This also requires you to use Android Studio Canary builds. Preview builds can be installed side by side with stable versions.