Skip to content

Commit

Permalink
Change LottieAnimationHelpers default animation cache to LRUAnimation…
Browse files Browse the repository at this point in the history
…Cache.shared (#1773) (#1778)
  • Loading branch information
pejato authored Oct 17, 2022
1 parent cb14050 commit 018e3fa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/Public/Animation/LottieAnimationHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ extension LottieAnimation {
/// - Parameter name: The name of the json file without the json extension. EG "StarAnimation"
/// - Parameter bundle: The bundle in which the animation is located. Defaults to `Bundle.main`
/// - Parameter subdirectory: A subdirectory in the bundle in which the animation is located. Optional.
/// - Parameter animationCache: A cache for holding loaded animations. Optional.
/// - Parameter animationCache: A cache for holding loaded animations. Defaults to `LRUAnimationCache.sharedCache`. Optional.
///
/// - Returns: Deserialized `LottieAnimation`. Optional.
public static func named(
_ name: String,
bundle: Bundle = Bundle.main,
subdirectory: String? = nil,
animationCache: AnimationCacheProvider? = nil)
animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache)
-> LottieAnimation?
{
/// Create a cache key for the animation.
Expand Down Expand Up @@ -74,12 +74,12 @@ extension LottieAnimation {

/// Loads an animation from a specific filepath.
/// - Parameter filepath: The absolute filepath of the animation to load. EG "/User/Me/starAnimation.json"
/// - Parameter animationCache: A cache for holding loaded animations. Optional.
/// - Parameter animationCache: A cache for holding loaded animations. Defaults to `LRUAnimationCache.sharedCache`. Optional.
///
/// - Returns: Deserialized `LottieAnimation`. Optional.
public static func filepath(
_ filepath: String,
animationCache: AnimationCacheProvider? = nil)
animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache)
-> LottieAnimation?
{
/// Check cache for animation
Expand All @@ -105,12 +105,12 @@ extension LottieAnimation {
/// Loads an animation model from the asset catalog by its name. Returns `nil` if an animation is not found.
/// - Parameter name: The name of the json file in the asset catalog. EG "StarAnimation"
/// - Parameter bundle: The bundle in which the animation is located. Defaults to `Bundle.main`
/// - Parameter animationCache: A cache for holding loaded animations. Optional.
/// - Parameter animationCache: A cache for holding loaded animations. Defaults to `LRUAnimationCache.sharedCache` Optional.
/// - Returns: Deserialized `LottieAnimation`. Optional.
public static func asset(
_ name: String,
bundle: Bundle = Bundle.main,
animationCache: AnimationCacheProvider? = nil)
animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache)
-> LottieAnimation?
{
/// Create a cache key for the animation.
Expand Down Expand Up @@ -168,13 +168,13 @@ extension LottieAnimation {
///
/// - Parameter url: The url to load the animation from.
/// - Parameter closure: A closure to be called when the animation has loaded.
/// - Parameter animationCache: A cache for holding loaded animations.
/// - Parameter animationCache: A cache for holding loaded animations. Defaults to `LRUAnimationCache.sharedCache`. Optional.
///
public static func loadedFrom(
url: URL,
session: URLSession = .shared,
closure: @escaping LottieAnimation.DownloadClosure,
animationCache: AnimationCacheProvider?)
animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache)
{
if let animationCache = animationCache, let animation = animationCache.animation(forKey: url.absoluteString) {
closure(animation)
Expand Down

0 comments on commit 018e3fa

Please sign in to comment.