Add Animator.AnimatorPauseListener support (#1662)
Resolves #1644 by adding methods to LottieAnimationView and LottieDrawable
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
index 70f0a9a..c5c38f6 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
@@ -24,6 +24,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
+import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.view.ViewCompat;
@@ -759,6 +760,16 @@
lottieDrawable.removeAllAnimatorListeners();
}
+ @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+ public void addAnimatorPauseListener(Animator.AnimatorPauseListener listener) {
+ lottieDrawable.addAnimatorPauseListener(listener);
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+ public void removeAnimatorPauseListener(Animator.AnimatorPauseListener listener) {
+ lottieDrawable.removeAnimatorPauseListener(listener);
+ }
+
/**
* @see #setRepeatCount(int)
*/
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
index e171b4b..ee145cc 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
@@ -44,6 +44,7 @@
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
/**
* This can be used to show an lottie animation in any place that would normally take a drawable.
@@ -742,6 +743,12 @@
animator.removeAllListeners();
}
+ @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+ public void addAnimatorPauseListener(Animator.AnimatorPauseListener listener) { animator.addPauseListener(listener); }
+
+ @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+ public void removeAnimatorPauseListener(Animator.AnimatorPauseListener listener) { animator.removePauseListener(listener); }
+
/**
* Sets the progress to the specified frame.
* If the composition isn't set yet, the progress will be set to the frame when