Permalink
Browse files

Fix references to deprecated assets in separate bundles

Reviewed By: sahrens

Differential Revision: D5346879

fbshipit-source-id: 9d1008765514006deef2182e61f42a7247ea9a85
  • Loading branch information...
javache authored and facebook-github-bot committed Jun 30, 2017
1 parent d494282 commit 12ab2366297948a4e37d3f6409e851e6c2246f50
Showing with 12 additions and 17 deletions.
  1. +3 −12 React/Base/RCTConvert.m
  2. +9 −5 React/Base/RCTUtils.m
View
@@ -736,7 +736,7 @@ + (UIImage *)UIImage:(id)json
// thread safe, so we'll pick the lesser of two evils here and block rather
// than run the risk of crashing
RCTLogWarn(@"Calling [RCTConvert UIImage:] on a background thread is not recommended");
dispatch_sync(dispatch_get_main_queue(), ^{
RCTUnsafeExecuteOnMainQueueSync(^{
image = [self UIImage:json];
});
return image;
@@ -745,18 +745,9 @@ + (UIImage *)UIImage:(id)json
NSURL *URL = imageSource.request.URL;
NSString *scheme = URL.scheme.lowercaseString;
if ([scheme isEqualToString:@"file"]) {
NSString *assetName = RCTBundlePathForURL(URL);
image = assetName ? [UIImage imageNamed:assetName] : nil;
image = RCTImageFromLocalAssetURL(URL);
if (!image) {
// Attempt to load from the file system
NSString *filePath = URL.path;
if (filePath.pathExtension.length == 0) {
filePath = [filePath stringByAppendingPathExtension:@"png"];
}
image = [UIImage imageWithContentsOfFile:filePath];
if (!image) {
RCTLogConvertError(json, @"an image. File not found.");
}
RCTLogConvertError(json, @"an image. File not found.");
}
} else if ([scheme isEqualToString:@"data"]) {
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:URL]];
View
@@ -643,10 +643,6 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL)
UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
{
if (!RCTIsLocalAssetURL(imageURL)) {
return nil;
}
NSString *imageName = RCTBundlePathForURL(imageURL);
NSBundle *bundle = nil;
@@ -665,6 +661,15 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL)
image = [UIImage imageNamed:imageName];
}
if (!image) {
// Attempt to load from the file system
NSString *filePath = imageURL.path;
if (filePath.pathExtension.length == 0) {
filePath = [filePath stringByAppendingPathExtension:@"png"];
}
image = [UIImage imageWithContentsOfFile:filePath];
}
if (!image && !bundle) {
// We did not find the image in the mainBundle, check in other shipped frameworks.
NSArray<NSURL *> *possibleFrameworks = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[[NSBundle mainBundle] privateFrameworksURL]
@@ -680,7 +685,6 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL)
}
}
}
return image;
}

0 comments on commit 12ab236

Please sign in to comment.