From 9d77268f9bb1d42c9bcc3ac1a8af7c9c80b4328f Mon Sep 17 00:00:00 2001 From: Sergei Dryganets Date: Sun, 18 Mar 2018 18:56:07 -0700 Subject: [PATCH] DEFAULT_CACHE_STRATEGY exposed. This is needed in order to make more sophisticated and efficient update for the react-native plugin for Android. (#691) --- .../java/com/airbnb/lottie/LottieAnimationView.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java index 2bc075ee07..c700486796 100644 --- a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java +++ b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java @@ -50,8 +50,12 @@ * {@link R.attr#lottie_progress} */ @SuppressWarnings({"unused", "WeakerAccess"}) public class LottieAnimationView extends AppCompatImageView { + + public static final CacheStrategy DEFAULT_CACHE_STRATEGY = CacheStrategy.Weak; + private static final String TAG = LottieAnimationView.class.getSimpleName(); + /** * Caching strategy for compositions that will be reused frequently. * Weak or Strong indicates the GC reference strength of the composition in the cache. @@ -109,10 +113,10 @@ public LottieAnimationView(Context context, AttributeSet attrs, int defStyleAttr private void init(@Nullable AttributeSet attrs) { TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LottieAnimationView); - int cacheStrategy = ta.getInt( + int cacheStrategyOrdinal = ta.getInt( R.styleable.LottieAnimationView_lottie_cacheStrategy, - CacheStrategy.Weak.ordinal()); - defaultCacheStrategy = CacheStrategy.values()[cacheStrategy]; + DEFAULT_CACHE_STRATEGY.ordinal()); + this.defaultCacheStrategy = CacheStrategy.values()[cacheStrategyOrdinal]; if (!isInEditMode()) { boolean hasRawRes = ta.hasValue(R.styleable.LottieAnimationView_lottie_rawRes); boolean hasFileName = ta.hasValue(R.styleable.LottieAnimationView_lottie_fileName);