Fix a crash in Image when passed an invalid uri

Summary:
public

Fix https://github.com/facebook/react-native/issues/5465

Instead of returning null when we fail to parse the Uri, just return an empty Uri which somewhat hides the problem but does prevent the crash

Reviewed By: mkonicek

Differential Revision: D2854902

fb-gh-sync-id: 71265d5e52302e174b898af5be25ac698abcf9ab
This commit is contained in:
Dave Miller
2016-01-22 10:37:44 -08:00
committed by facebook-github-bot-4
parent cd2eed0d36
commit 798acac18e

View File

@@ -352,11 +352,11 @@ public class ReactImageView extends GenericDraweeView {
return resId > 0 ? context.getResources().getDrawable(resId) : null;
}
private static @Nullable Uri getResourceDrawableUri(Context context, @Nullable String name) {
private static Uri getResourceDrawableUri(Context context, @Nullable String name) {
int resId = getResourceDrawableId(context, name);
return resId > 0 ? new Uri.Builder()
.scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
.path(String.valueOf(resId))
.build() : null;
.build() : Uri.EMPTY;
}
}