Skip to content

Instantly share code, notes, and snippets.

@mukyasa
Created June 6, 2020 08:03
Show Gist options
  • Save mukyasa/f309f737d143da40ee7cd29fe840e806 to your computer and use it in GitHub Desktop.
Save mukyasa/f309f737d143da40ee7cd29fe840e806 to your computer and use it in GitHub Desktop.
public class LottieAnimationCache: AnimationCacheProvider {
fileprivate var cacheAnimation: Animation!
public init() {}
/// Clears the Cache.
public func clearCache() {
}
/// The global shared Cache.
public static let sharedCache = LottieAnimationCache()
public func animation(forKey: String) -> Animation? {
if cacheAnimation != nil {
return cacheAnimation
}
guard let animation = CodableStorageHelper<Animation>.getValueFor(key: forKey) else {
return nil
}
cacheAnimation = animation
return cacheAnimation
}
public func setAnimation(_ animation: Animation, forKey: String) {
CodableStorageHelper<Animation>.setValue(animation,
key: forKey)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment