Skip to content

Commit

Permalink
Use LOTCacheProvider in LOTLayerView
Browse files Browse the repository at this point in the history
  • Loading branch information
panmingyang2009 committed Aug 3, 2017
1 parent 2ae59bc commit 74b7144
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lottie-ios/Classes/AnimatableLayers/LOTLayerContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#import "LOTMaskContainer.h"
#import "LOTAsset.h"

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#import "LOTCacheProvider.h"
#endif

@implementation LOTLayerContainer {
LOTTransformInterpolator *_transformInterpolator;
LOTNumberInterpolator *_opacityInterpolator;
Expand Down Expand Up @@ -128,7 +132,17 @@ - (void)_setImageForAsset:(LOTAsset *)asset {
rootDirectory = [rootDirectory stringByAppendingPathComponent:asset.imageDirectory];
}
NSString *imagePath = [rootDirectory stringByAppendingPathComponent:asset.imageName];
image = [UIImage imageWithContentsOfFile:imagePath];

id<LOTImageCache> imageCache = [LOTCacheProvider imageCache];
if (imageCache) {
image = [imageCache imageForKey:imagePath];
if (!image) {
image = [UIImage imageWithContentsOfFile:imagePath];
[imageCache setImage:image forKey:imagePath];
}
} else {
image = [UIImage imageWithContentsOfFile:imagePath];
}
}else{
NSArray *components = [asset.imageName componentsSeparatedByString:@"."];
image = [UIImage imageNamed:components.firstObject inBundle:asset.assetBundle compatibleWithTraitCollection:nil];
Expand Down

0 comments on commit 74b7144

Please sign in to comment.