@Test public void testOnLoadEventEmitted () { verify(mEventEmitter, never()).receiveEvent(anyInt(), anyString(), any(WritableMap.class)); WebImageViewTarget target = new WebImageViewTarget(mImageView); Bitmap bitmap = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_8888); mViewManager.mRequestListener.onResourceReady(bitmap, null, target, null, true); WritableMap expectedSource = new JavaOnlyMap(); expectedSource.putString("uri", "http: expectedSource.putInt("width", 64); expectedSource.putInt("height", 64); WritableMap expectedEvent = new JavaOnlyMap(); expectedEvent.putMap("source", expectedSource); verify(mEventEmitter).receiveEvent(-1, "onWebImageLoad", expectedEvent); }
@Override public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { WebImageView view = null; if (target instanceof WebImageViewTarget) { view = ((WebImageViewTarget) target).getView(); } Bitmap bitmap = null; if (resource instanceof Bitmap) { bitmap = (Bitmap) resource; } if (view != null) { ThemedReactContext context = view.getThemedReactContext(); if (context != null) { WritableMap event = createMap(); WritableMap source = createMap(); final GlideUrl uri = view.getImageUri(); if (uri != null) { source.putString("uri", uri.toStringUrl()); } if (bitmap != null) { source.putInt("width", bitmap.getWidth()); source.putInt("height", bitmap.getHeight()); } event.putMap("source", source); context.getJSModule(RCTEventEmitter.class).receiveEvent(view.getId(), "onWebImageLoad", event); } } return false; }
RequestListener implements com.bumptech.glide.request.RequestListener { @Override public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { WebImageView view = null; if (target instanceof WebImageViewTarget) { view = ((WebImageViewTarget) target).getView(); } Bitmap bitmap = null; if (resource instanceof Bitmap) { bitmap = (Bitmap) resource; } if (view != null) { ThemedReactContext context = view.getThemedReactContext(); if (context != null) { WritableMap event = createMap(); WritableMap source = createMap(); final GlideUrl uri = view.getImageUri(); if (uri != null) { source.putString("uri", uri.toStringUrl()); } if (bitmap != null) { source.putInt("width", bitmap.getWidth()); source.putInt("height", bitmap.getHeight()); } event.putMap("source", source); context.getJSModule(RCTEventEmitter.class).receiveEvent(view.getId(), "onWebImageLoad", event); } } return false; } }
RequestListener implements com.bumptech.glide.request.RequestListener { @Override public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { WebImageView view = null; if (target instanceof WebImageViewTarget) { view = ((WebImageViewTarget) target).getView(); } Bitmap bitmap = null; if (resource instanceof Bitmap) { bitmap = (Bitmap) resource; } if (view != null) { ThemedReactContext context = view.getThemedReactContext(); if (context != null) { WritableMap event = createMap(); WritableMap source = createMap(); final GlideUrl uri = view.getImageUri(); if (uri != null) { source.putString("uri", uri.toStringUrl()); } if (bitmap != null) { source.putInt("width", bitmap.getWidth()); source.putInt("height", bitmap.getHeight()); } event.putMap("source", source); context.getJSModule(RCTEventEmitter.class).receiveEvent(view.getId(), "onWebImageLoad", event); } } return false; }  }
RequestListener implements com.bumptech.glide.request.RequestListener { @Override public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { WebImageView view = null; if (target instanceof WebImageViewTarget) { view = ((WebImageViewTarget) target).getView(); } Bitmap bitmap = null; if (resource instanceof Bitmap) { bitmap = (Bitmap) resource; } if (view != null) { ThemedReactContext context = view.getThemedReactContext(); if (context != null) { WritableMap event = createMap(); WritableMap source = createMap(); final GlideUrl uri = view.getImageUri(); if (uri != null) { source.putString("uri", uri.toStringUrl()); } if (bitmap != null) { source.putInt("width", bitmap.getWidth()); source.putInt("height", bitmap.getHeight()); } event.putMap("source", source); context.getJSModule(RCTEventEmitter.class).receiveEvent(view.getId(), "onWebImageLoad", event); } } return false; }  @Override boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource); @Override boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource); }
RequestListener implements com.bumptech.glide.request.RequestListener { @Override public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { WebImageView view = null; if (target instanceof WebImageViewTarget) { view = ((WebImageViewTarget) target).getView(); } Bitmap bitmap = null; if (resource instanceof Bitmap) { bitmap = (Bitmap) resource; } if (view != null) { ThemedReactContext context = view.getThemedReactContext(); if (context != null) { WritableMap event = createMap(); WritableMap source = createMap(); final GlideUrl uri = view.getImageUri(); if (uri != null) { source.putString("uri", uri.toStringUrl()); } if (bitmap != null) { source.putInt("width", bitmap.getWidth()); source.putInt("height", bitmap.getHeight()); } event.putMap("source", source); context.getJSModule(RCTEventEmitter.class).receiveEvent(view.getId(), "onWebImageLoad", event); } } return false; }  @Override boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource); @Override boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource);  }