From 7f028f0e82cd2ec38fc594675b788215845e7978 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 19 Feb 2020 17:12:50 -0500 Subject: [PATCH] Fixes to allow bundle improvements --- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h | 2 +- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h index ad6b87b..3095540 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h @@ -123,7 +123,7 @@ typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOO // localFallbackImageName: should be the name of a local file to use in case of failure to download. - (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 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; // Gets a cropped version of the requested image. Similar to the method above, but you can specify the final rect diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index f55d0c2..238b9d9 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -460,15 +460,15 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; } - (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 { - [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:nil finalRect:CGRectNull flipImage:NO localFallbackImageName:fallbackImageName allowServerQueryParameters:NO completionHandler:completionHandler]; + [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:nil finalRect:CGRectNull flipImage:NO localFallbackImageName:fallbackImageName allowServerQueryParameters:NO localBundle:nil completionHandler: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 { - [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:format finalRect:CGRectNull flipImage:NO localFallbackImageName:fallbackImageName allowServerQueryParameters:NO completionHandler:completionHandler]; + [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:format finalRect:CGRectNull flipImage:NO localFallbackImageName:fallbackImageName allowServerQueryParameters:NO localBundle:nil completionHandler: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 completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler { - [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:format finalRect:CGRectNull flipImage:NO localFallbackImageName:fallbackImageName allowServerQueryParameters:allowServerParams completionHandler: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 { + [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 { @@ -500,15 +500,15 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; - (void)getCroppedImage:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 finalRect:(CGRect)finalRect flipImage:(BOOL)flip localFallbackImageName:(nullable NSString *)fallbackImageName completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler { - [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:nil finalRect:finalRect flipImage:flip localFallbackImageName:fallbackImageName allowServerQueryParameters:NO completionHandler:completionHandler]; + [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:nil finalRect:finalRect flipImage:flip localFallbackImageName:fallbackImageName allowServerQueryParameters:NO localBundle:nil completionHandler:completionHandler]; } - (void)getCroppedImage:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 finalRect:(CGRect)finalRect flipImage:(BOOL)flip localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)allowServerParams completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler { - [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:nil finalRect:finalRect flipImage:flip localFallbackImageName:fallbackImageName allowServerQueryParameters:allowServerParams completionHandler:completionHandler]; + [self getImage:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:nil finalRect:finalRect flipImage:flip localFallbackImageName:fallbackImageName allowServerQueryParameters:allowServerParams localBundle:nil completionHandler:completionHandler]; } -- (void)getImage:(nullable NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format finalRect:(CGRect)finalRect flipImage:(BOOL)flip localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)serverQueryParams 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 finalRect:(CGRect)finalRect flipImage:(BOOL)flip localFallbackImageName:(nullable NSString *)fallbackImageName allowServerQueryParameters:(BOOL)serverQueryParams localBundle:(nullable NSBundle *)localBundle completionHandler:(nonnull MVMCoreGetImageBlock)completionHandler { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ UIImage *image = nil; if (pathOrName.length > 0) { @@ -524,7 +524,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; // Try native image. Check in memory cache image = [self getCachedImageWithName:pathOrName]; if (!image) { - image = [UIImage imageNamed:pathOrName inBundle:[self bundleToUseForImages] compatibleWithTraitCollection:nil]; + image = [UIImage imageNamed:pathOrName inBundle:localBundle ?: [self bundleToUseForImages] compatibleWithTraitCollection:nil]; if (image) { [self addImageToCache:image withName:pathOrName]; }