From 5ad87445d88a1430c73c2259accce1e79a164a31 Mon Sep 17 00:00:00 2001 From: Gabriel Peal Date: Mon, 26 Feb 2024 17:28:38 -0800 Subject: [PATCH] Respect autoPlay when setting a new composition (#2469) Fixes #2464 --- .../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 d1f4cd497a..273ba7030c 100644 --- a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java +++ b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java @@ -641,6 +641,9 @@ public void setComposition(@NonNull LottieComposition 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 @@ -1080,6 +1083,7 @@ public void addValueCallback(KeyPath keyPath, T property, @MainThread public void cancelAnimation() { + autoPlay = false; userActionsTaken.add(UserActionTaken.PLAY_OPTION); lottieDrawable.cancelAnimation(); }