Skip to content

Commit

Permalink
Cache compositions loaded by url in memory (#1657)
Browse files Browse the repository at this point in the history
Fixes #1648
  • Loading branch information
gpeal authored Oct 24, 2020
1 parent b27f6d3 commit 19cf3f0
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ public static LottieTask<LottieComposition> fromUrl(final Context context, final
return cache(cacheKey, new Callable<LottieResult<LottieComposition>>() {
@Override
public LottieResult<LottieComposition> call() {
return L.networkFetcher(context).fetchSync(url, cacheKey);
LottieResult<LottieComposition> result = L.networkFetcher(context).fetchSync(url, cacheKey);
if (cacheKey != null && result.getValue() != null) {
LottieCompositionCache.getInstance().put(cacheKey, result.getValue());
}
return result;
}
});
}
Expand All @@ -109,7 +113,11 @@ public static LottieResult<LottieComposition> fromUrlSync(Context context, Strin
*/
@WorkerThread
public static LottieResult<LottieComposition> fromUrlSync(Context context, String url, @Nullable String cacheKey) {
return L.networkFetcher(context).fetchSync(url, cacheKey);
LottieResult<LottieComposition> result = L.networkFetcher(context).fetchSync(url, cacheKey);
if (cacheKey != null && result.getValue() != null) {
LottieCompositionCache.getInstance().put(cacheKey, result.getValue());
}
return result;
}

/**
Expand Down

0 comments on commit 19cf3f0

Please sign in to comment.