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 09de651a9..a099d08a8 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 @@ -28,8 +28,11 @@ import android.graphics.RectF; import android.graphics.Shader; import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.widget.Toast; import com.facebook.common.util.UriUtil; +import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.yoga.YogaConstants; import com.facebook.drawee.controller.AbstractDraweeControllerBuilder; import com.facebook.drawee.controller.BaseControllerListener; @@ -270,15 +273,26 @@ public class ReactImageView extends GenericDraweeView { 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) { - mSources.add(new ImageSource(getContext(), sources.getMap(0).getString("uri"))); + ReadableMap source = sources.getMap(0); + String uri = source.getString("uri"); + ImageSource imageSource = new ImageSource(getContext(), uri); + mSources.add(imageSource); + if (Uri.EMPTY.equals(imageSource.getUri())) { + warnImageSource(uri); + } } else { for (int idx = 0; idx < sources.size(); idx++) { ReadableMap source = sources.getMap(idx); - mSources.add(new ImageSource( - getContext(), - source.getString("uri"), - source.getDouble("width"), - source.getDouble("height"))); + String uri = source.getString("uri"); + ImageSource imageSource = new ImageSource( + getContext(), + uri, + source.getDouble("width"), + source.getDouble("height")); + mSources.add(imageSource); + if (Uri.EMPTY.equals(imageSource.getUri())) { + warnImageSource(uri); + } } } } @@ -470,4 +484,13 @@ public class ReactImageView extends GenericDraweeView { return false; } } + + private void warnImageSource(String uri) { + if (ReactBuildConfig.DEBUG) { + Toast.makeText( + getContext(), + "Warning: Image source \"" + uri + "\" doesn't exist", + Toast.LENGTH_SHORT).show(); + } + } }