height changes minor

This commit is contained in:
Pfeil, Scott Robert 2019-08-19 13:30:50 -04:00
parent db1e3fd04c
commit 310af60183
2 changed files with 10 additions and 3 deletions

View File

@ -111,6 +111,9 @@ typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOO
// Subclass to return the bundle to use
- (nonnull NSBundle *)bundleToUseForImages;
/// Returns if the imageName pointing to a local image. Currently just checks if it begins with http.
+ (BOOL)isHostedImage:(nullable NSString *)imageName;
// Checks if the image is in the cache. If not, will try to download or create the image.
// Width is used for downloading from scene7.
// Height is used for downloading from scene7.

View File

@ -387,6 +387,10 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
return _imgCache;
}
+ (BOOL)isHostedImage:(nullable NSString *)imageName {
return imageName.length >=4 && [[imageName substringToIndex:4] isEqualToString:@"http"];
}
- (NSURL *)handleS7Path:(NSString *)pathOrName useWidth:(BOOL)useWidth widthForS7:(NSInteger)widthForS7 useHeight:(BOOL)useHeight heightForS7:(NSInteger)heightForS7 format:(nullable NSString *)format finalRect:(CGRect)finalRect flipImage:(BOOL)flipImage {
// For scene 7
@ -466,7 +470,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *imageData = nil;
if (pathOrName.length > 0) {
if (pathOrName.length >=4 && [[pathOrName substringToIndex:4] isEqualToString:@"http"]) {
if ([MVMCoreCache isHostedImage:pathOrName]) {
// Gets the full path
NSURL *s7URL = [self handleS7Path:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:format finalRect:CGRectNull flipImage:NO];
if (s7URL) {
@ -498,7 +502,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
UIImage *image = nil;
if (pathOrName.length > 0) {
// try the url if it's a url.
if (pathOrName.length >=4 && [[pathOrName substringToIndex:4] isEqualToString:@"http"]) {
if ([MVMCoreCache isHostedImage:pathOrName]) {
// Gets the full path
NSURL *s7URL = [self handleS7Path:pathOrName useWidth:useWidth widthForS7:widthForS7 useHeight:useHeight heightForS7:heightForS7 format:format finalRect:finalRect flipImage:flip];
if (s7URL) {
@ -633,7 +637,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
if (imageName) {
dispatch_barrier_async(self.imageCacheQueue, ^{
if ([imageName hasPrefix:@"http"]) {
if ([MVMCoreCache isHostedImage:imageName]) {
for (NSString *key in self.imgCache.allKeys) {
NSURLComponents *components = [[NSURLComponents alloc] initWithString:key];
if (components) {