From b60a3532c4471b4cc1a37f42802a29e94ec6cccb Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Sun, 12 Apr 2020 19:25:20 -0400 Subject: [PATCH] bugfix for load gif file form different bundle --- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h | 2 +- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h index 3095540..9d97932 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h @@ -124,7 +124,7 @@ typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOO - (void)getImage:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 localFallbackImageName:(nullable NSString *)fallbackImageName completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler; - (void)getImage:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format localFallbackImageName:(nullable NSString *)fallbackImageName completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler; - (void)getImage:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)allowServerParams localBundle:(nullable NSBundle *)localBundle completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler; -- (void)getGif:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)allowServerParams completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler; +- (void)getGif:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)allowServerParams localBundle:(nullable NSBundle *)localBundle completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler; // Gets a cropped version of the requested image. Similar to the method above, but you can specify the final rect - (void)getCroppedImage:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 finalRect:(CGRect)finalRect flipImage:(BOOL)flipImage localFallbackImageName:(nullable NSString *)fallbackImageName completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler; diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index d7b79a8..0d552c3 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -471,7 +471,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:format finalRect:CGRectNull flipImage:NO localFallbackImageName:fallbackImageName allowServerQueryParameters:allowServerParams localBundle:localBundle completionHandler:completionHandler]; } -- (void)getGif:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)allowServerParams completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler { +- (void)getGif:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)allowServerParams localBundle:(nullable NSBundle *)localBundle completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData *imageData = nil; @@ -487,7 +487,8 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; // Try Local. Check in memory cache imageData = [self getCachedDataWithName:pathOrName]; if (!imageData) { - imageData = [NSData dataWithContentsOfFile:[[self bundleToUseForImages] pathForResource:pathOrName ofType:@"gif"]]; + NSBundle *imageBundle = localBundle ? : [self bundleToUseForImages]; + imageData = [NSData dataWithContentsOfFile:[imageBundle pathForResource:pathOrName ofType:@"gif"]]; if (imageData) { [self addDataToCache:imageData withName:pathOrName]; }