From bc3a763c92c16dd91f058d060b46a55a8ac212cc Mon Sep 17 00:00:00 2001 From: Gabriel Peal Date: Mon, 26 Feb 2024 19:18:23 -0500 Subject: [PATCH] Respect autoPlay when setting a new composition --- .../src/main/java/com/airbnb/lottie/LottieAnimationView.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java index 3c736abd7e..63afac5756 100644 --- a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java +++ b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java @@ -639,6 +639,9 @@ public void setComposition(@NonNull LottieComposition composition) { this.composition = composition; ignoreUnschedule = true; boolean isNewComposition = lottieDrawable.setComposition(composition); + if (autoPlay) { + lottieDrawable.playAnimation(); + } ignoreUnschedule = false; if (getDrawable() == lottieDrawable && !isNewComposition) { // We can avoid re-setting the drawable, and invalidating the view, since the composition @@ -1078,6 +1081,7 @@ public void addValueCallback(KeyPath keyPath, T property, @MainThread public void cancelAnimation() { + autoPlay = false; userActionsTaken.add(UserActionTaken.PLAY_OPTION); lottieDrawable.cancelAnimation(); }