diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java b/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java index f4a1a6ab69..0c686f7202 100644 --- a/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java +++ b/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java @@ -86,7 +86,11 @@ public static LottieTask fromUrl(final Context context, final return cache(cacheKey, new Callable>() { @Override public LottieResult call() { - return L.networkFetcher(context).fetchSync(url, cacheKey); + LottieResult result = L.networkFetcher(context).fetchSync(url, cacheKey); + if (cacheKey != null && result.getValue() != null) { + LottieCompositionCache.getInstance().put(cacheKey, result.getValue()); + } + return result; } }); } @@ -109,7 +113,11 @@ public static LottieResult fromUrlSync(Context context, Strin */ @WorkerThread public static LottieResult fromUrlSync(Context context, String url, @Nullable String cacheKey) { - return L.networkFetcher(context).fetchSync(url, cacheKey); + LottieResult result = L.networkFetcher(context).fetchSync(url, cacheKey); + if (cacheKey != null && result.getValue() != null) { + LottieCompositionCache.getInstance().put(cacheKey, result.getValue()); + } + return result; } /**