Merge branch 'bugfix/image' into 'develop'

bugfix for load gif file form different bundle

See merge request BPHV_MIPS/mvm_core!78
This commit is contained in:
Pfeil, Scott Robert 2020-04-13 09:16:58 -04:00
commit 18ffc7e203
2 changed files with 4 additions and 3 deletions

View File

@ -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;

View File

@ -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];
}