fix: do not crash when source is invalid (#782)
To reproduce, you can use: `source={{ uri: '/' }}`
This commit is contained in:
parent
716c01a967
commit
5c5fefacbd
|
@ -72,6 +72,27 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
||||||
|
|
||||||
//final GlideUrl glideUrl = FastImageViewConverter.getGlideUrl(view.getContext(), source);
|
//final GlideUrl glideUrl = FastImageViewConverter.getGlideUrl(view.getContext(), source);
|
||||||
final FastImageSource imageSource = FastImageViewConverter.getImageSource(view.getContext(), source);
|
final FastImageSource imageSource = FastImageViewConverter.getImageSource(view.getContext(), source);
|
||||||
|
if (imageSource.getUri().toString().length() == 0) {
|
||||||
|
ThemedReactContext context = (ThemedReactContext) view.getContext();
|
||||||
|
RCTEventEmitter eventEmitter = context.getJSModule(RCTEventEmitter.class);
|
||||||
|
int viewId = view.getId();
|
||||||
|
WritableMap event = new WritableNativeMap();
|
||||||
|
event.putString("message", "Invalid source prop:" + source);
|
||||||
|
eventEmitter.receiveEvent(viewId, REACT_ON_ERROR_EVENT, event);
|
||||||
|
|
||||||
|
// Cancel existing requests.
|
||||||
|
if (requestManager != null) {
|
||||||
|
requestManager.clear(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view.glideUrl != null) {
|
||||||
|
FastImageOkHttpProgressGlideModule.forget(view.glideUrl.toStringUrl());
|
||||||
|
}
|
||||||
|
// Clear the image.
|
||||||
|
view.setImageDrawable(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final GlideUrl glideUrl = imageSource.getGlideUrl();
|
final GlideUrl glideUrl = imageSource.getGlideUrl();
|
||||||
|
|
||||||
// Cancel existing request.
|
// Cancel existing request.
|
||||||
|
|
Loading…
Reference in New Issue