mirror of
https://github.com/svga/SVGAPlayer-iOS.git
synced 2025-10-20 23:19:13 +08:00
fix: cache added synchronized
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SVGAPlayer"
|
||||
s.version = "2.5.4"
|
||||
s.version = "2.5.5"
|
||||
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
|
||||
s.description = <<-DESC
|
||||
SVGA 是一种全新的动画格式,由 YY UED 团队主导开发;
|
||||
|
@@ -50,6 +50,7 @@ static SVGAParser *parser;
|
||||
@"https://github.com/yyued/SVGA-Samples/blob/master/rose.svga?raw=true",
|
||||
];
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
|
||||
// parser.enabledMemoryCache = YES;
|
||||
[parser parseWithURL:[NSURL URLWithString:items[arc4random() % items.count]]
|
||||
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
|
||||
@@ -66,6 +67,7 @@ static SVGAParser *parser;
|
||||
NSParagraphStyleAttributeName: para,
|
||||
}];
|
||||
[self.aPlayer setAttributedText:str forKey:@"banner"];
|
||||
|
||||
// self.aPlayer.mianRunLoopMode = NSDefaultRunLoopMode;
|
||||
[self.aPlayer startAnimation];
|
||||
}
|
||||
|
@@ -209,19 +209,27 @@ static NSMapTable * weakCache;
|
||||
}
|
||||
|
||||
+ (SVGAVideoEntity *)readCache:(NSString *)cacheKey {
|
||||
SVGAVideoEntity * object = [videoCache objectForKey:cacheKey];
|
||||
if (!object) {
|
||||
object = [weakCache objectForKey:cacheKey];
|
||||
@synchronized (videoCache) {
|
||||
SVGAVideoEntity * object = [videoCache objectForKey:cacheKey];
|
||||
if (!object) {
|
||||
@synchronized (weakCache) {
|
||||
object = [weakCache objectForKey:cacheKey];
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
- (void)saveCache:(NSString *)cacheKey {
|
||||
[videoCache setObject:self forKey:cacheKey];
|
||||
@synchronized (videoCache) {
|
||||
[videoCache setObject:self forKey:cacheKey];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)saveWeakCache:(NSString *)cacheKey {
|
||||
[weakCache setObject:self forKey:cacheKey];
|
||||
@synchronized (weakCache) {
|
||||
[weakCache setObject:self forKey:cacheKey];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user