From 34dc62322962b6ba8e7bf0d1a7248162ceecf775 Mon Sep 17 00:00:00 2001 From: Gabriel Peal Date: Sat, 3 Jul 2021 15:12:54 -0700 Subject: [PATCH] Use app context in NetworkFetcher (#1832) Fixes #1798 --- lottie/src/main/java/com/airbnb/lottie/L.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/L.java b/lottie/src/main/java/com/airbnb/lottie/L.java index 7dbc35c4df..180bfbaef0 100644 --- a/lottie/src/main/java/com/airbnb/lottie/L.java +++ b/lottie/src/main/java/com/airbnb/lottie/L.java @@ -105,6 +105,7 @@ public static NetworkFetcher networkFetcher(@NonNull Context context) { @NonNull public static NetworkCache networkCache(@NonNull final Context context) { + final Context appContext = context.getApplicationContext(); NetworkCache local = networkCache; if (local == null) { synchronized (NetworkCache.class) { @@ -112,7 +113,7 @@ public static NetworkCache networkCache(@NonNull final Context context) { if (local == null) { networkCache = local = new NetworkCache(cacheProvider != null ? cacheProvider : new LottieNetworkCacheProvider() { @Override @NonNull public File getCacheDir() { - return new File(context.getCacheDir(), "lottie_network_cache"); + return new File(appContext.getCacheDir(), "lottie_network_cache"); } }); }