From 816d302e98cb14224f8bb2772299f87777a26ef8 Mon Sep 17 00:00:00 2001 From: Himabindu Gadupudi Date: Fri, 6 Jul 2018 12:23:52 -0700 Subject: [PATCH] Reverting image source null so the fix can go all once later Summary: Image source null which is in RC D8628053 has a bug which has a fix but didn't make to RC. Reverting so it can be cleaned up before going in RC. Reviewed By: achen1 Differential Revision: D8751687 fbshipit-source-id: e08b23a031455be23047880871813bdc840542dd --- Libraries/Image/Image.android.js | 9 ++++++--- .../react/views/image/ReactImageView.java | 15 +++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 99636169f4c..d0e685a5e64 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -190,6 +190,9 @@ let Image = ( props.loadingIndicatorSource, ); + // As opposed to the ios version, here we render `null` when there is no source, source.uri + // or source array. + if (source && source.uri === '') { console.warn('source.uri should not be an empty string'); } @@ -212,13 +215,13 @@ let Image = ( ); } - if (source && !source?.uri && !Array.isArray(source)) { + if (!source || (!source.uri && !Array.isArray(source))) { return null; } let style; let sources; - if (source?.uri != null) { + if (source.uri) { const {width, height} = source; style = flattenStyle([{width, height}, styles.base, props.style]); sources = [{uri: source.uri}]; @@ -232,7 +235,7 @@ let Image = ( style, shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd || onError), src: sources, - headers: source?.headers, + headers: source.headers, defaultSrc: defaultSource ? defaultSource.uri : null, loadingIndicatorSrc: loadingIndicatorSource ? loadingIndicatorSource.uri diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java index cf7a1580fcb..91817b955b2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java @@ -1,3 +1,4 @@ + /** * Copyright (c) 2015-present, Facebook, Inc. * @@ -70,9 +71,6 @@ public class ReactImageView extends GenericDraweeView { public static final int REMOTE_IMAGE_FADE_DURATION_MS = 300; - public static final String REMOTE_TRANSPARENT_BITMAP_URI = - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; - private static float[] sComputedCornerRadii = new float[4]; /* @@ -341,10 +339,7 @@ public class ReactImageView extends GenericDraweeView { public void setSource(@Nullable ReadableArray sources) { mSources.clear(); - if (sources == null || sources.size() == 0) { - ImageSource imageSource = new ImageSource(getContext(), REMOTE_TRANSPARENT_BITMAP_URI); - mSources.add(imageSource); - } else { + if (sources != null && sources.size() != 0) { // Optimize for the case where we have just one uri, case in which we don't need the sizes if (sources.size() == 1) { ReadableMap source = sources.getMap(0); @@ -578,9 +573,9 @@ public class ReactImageView extends GenericDraweeView { private void setSourceImage() { mImageSource = null; if (mSources.isEmpty()) { - ImageSource imageSource = new ImageSource(getContext(), REMOTE_TRANSPARENT_BITMAP_URI); - mSources.add(imageSource); - } else if (hasMultipleSources()) { + return; + } + if (hasMultipleSources()) { MultiSourceResult multiSource = MultiSourceHelper.getBestSourceForSize(getWidth(), getHeight(), mSources); mImageSource = multiSource.getBestResult();