Skip to content

Commit

Permalink
Add an option to not clear the network cache (#2559)
Browse files Browse the repository at this point in the history
Fixes #2498
  • Loading branch information
gpeal authored Sep 29, 2024
1 parent 626f081 commit b15f9bf
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,27 @@ public static void setMaxCacheSize(int size) {
LottieCompositionCache.getInstance().resize(size);
}

/**
* Like {@link #clearCache(Context, boolean)} but defaults to clearing the network cache.
*
* @see #clearCache(Context, boolean)
*/
public static void clearCache(Context context) {
clearCache(context, true);
}

/**
* Clears any pending animations, animations that are parsed and in-memory, and
* optionally, any animations loaded from the network that are cached to disk.
*/
public static void clearCache(Context context, boolean includeNetwork) {
taskCache.clear();
LottieCompositionCache.getInstance().clear();
final NetworkCache networkCache = L.networkCache(context);
if (networkCache != null) {
networkCache.clear();
if (includeNetwork) {
final NetworkCache networkCache = L.networkCache(context);
if (networkCache != null) {
networkCache.clear();
}
}
}

Expand Down

0 comments on commit b15f9bf

Please sign in to comment.