Skip to content

Commit b15f9bf

Browse files
authored
Add an option to not clear the network cache (#2559)
Fixes #2498
1 parent 626f081 commit b15f9bf

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java

+18-3
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,27 @@ public static void setMaxCacheSize(int size) {
8686
LottieCompositionCache.getInstance().resize(size);
8787
}
8888

89+
/**
90+
* Like {@link #clearCache(Context, boolean)} but defaults to clearing the network cache.
91+
*
92+
* @see #clearCache(Context, boolean)
93+
*/
8994
public static void clearCache(Context context) {
95+
clearCache(context, true);
96+
}
97+
98+
/**
99+
* Clears any pending animations, animations that are parsed and in-memory, and
100+
* optionally, any animations loaded from the network that are cached to disk.
101+
*/
102+
public static void clearCache(Context context, boolean includeNetwork) {
90103
taskCache.clear();
91104
LottieCompositionCache.getInstance().clear();
92-
final NetworkCache networkCache = L.networkCache(context);
93-
if (networkCache != null) {
94-
networkCache.clear();
105+
if (includeNetwork) {
106+
final NetworkCache networkCache = L.networkCache(context);
107+
if (networkCache != null) {
108+
networkCache.clear();
109+
}
95110
}
96111
}
97112

0 commit comments

Comments
 (0)