mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 20:44:10 +00:00
Add warning for missing local image resources
Summary: Show a toast (since there isn't an easy way to show the yellow box) Reviewed By: AaaChiuuu Differential Revision: D4336435 fbshipit-source-id: 01b0dbdaabf51be3d23aab5c72ab2a701fcb8f80
This commit is contained in:
parent
709a441ecf
commit
5671dc3fae
@ -28,8 +28,11 @@ import android.graphics.RectF;
|
|||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.graphics.drawable.Animatable;
|
import android.graphics.drawable.Animatable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.facebook.common.util.UriUtil;
|
import com.facebook.common.util.UriUtil;
|
||||||
|
import com.facebook.react.common.build.ReactBuildConfig;
|
||||||
import com.facebook.yoga.YogaConstants;
|
import com.facebook.yoga.YogaConstants;
|
||||||
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
|
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
|
||||||
import com.facebook.drawee.controller.BaseControllerListener;
|
import com.facebook.drawee.controller.BaseControllerListener;
|
||||||
@ -270,15 +273,26 @@ public class ReactImageView extends GenericDraweeView {
|
|||||||
if (sources != null && sources.size() != 0) {
|
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
|
// Optimize for the case where we have just one uri, case in which we don't need the sizes
|
||||||
if (sources.size() == 1) {
|
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 {
|
} else {
|
||||||
for (int idx = 0; idx < sources.size(); idx++) {
|
for (int idx = 0; idx < sources.size(); idx++) {
|
||||||
ReadableMap source = sources.getMap(idx);
|
ReadableMap source = sources.getMap(idx);
|
||||||
mSources.add(new ImageSource(
|
String uri = source.getString("uri");
|
||||||
getContext(),
|
ImageSource imageSource = new ImageSource(
|
||||||
source.getString("uri"),
|
getContext(),
|
||||||
source.getDouble("width"),
|
uri,
|
||||||
source.getDouble("height")));
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void warnImageSource(String uri) {
|
||||||
|
if (ReactBuildConfig.DEBUG) {
|
||||||
|
Toast.makeText(
|
||||||
|
getContext(),
|
||||||
|
"Warning: Image source \"" + uri + "\" doesn't exist",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user