Fix LottieDrawable#start for non-View callbacks (#2056)
Previously, the start function would be a noop if your callback was something other than a View instance.
With this change, if you use a non-View Callback (such as a Drawable), start will still call playAnimation; if the Callback was a View, it must still not be in edit mode to call playAnimation.
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
index 3f01bd9..637e494 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
@@ -549,11 +549,12 @@
@MainThread
@Override
public void start() {
- // Don't auto play when in edit mode.
Callback callback = getCallback();
- if (callback instanceof View && !((View) callback).isInEditMode()) {
- playAnimation();
+ if (callback instanceof View && ((View) callback).isInEditMode()) {
+ // Don't auto play when in edit mode.
+ return;
}
+ playAnimation();
}
@MainThread