From 68b2f49a314ae07681353d89b89f2a7f28cef10d Mon Sep 17 00:00:00 2001 From: Olivier Notteghem Date: Tue, 10 May 2016 14:16:26 -0700 Subject: [PATCH] Improves react image loading handlers to mimic iOS behavior Reviewed By: vjeux Differential Revision: D3283011 fbshipit-source-id: acb04f8b2ccbab99a59040a7ca70aa46cbf73faa --- .../com/facebook/react/views/image/ImageLoadEvent.java | 2 +- .../com/facebook/react/views/image/ReactImageView.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java index 2e19ca0895a151..7dde489d8b839e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java @@ -26,7 +26,7 @@ public class ImageLoadEvent extends Event { @Retention(RetentionPolicy.SOURCE) @interface ImageEventType {} - // Currently ON_ERROR and ON_PROGRESS are not implemented, these can be added + // Currently ON_PROGRESS is not implemented, these can be added // easily once support exists in fresco. public static final int ON_ERROR = 1; public static final int ON_LOAD = 2; 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 7096fc3acd9ba8..10a474420ed4d6 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 @@ -193,10 +193,10 @@ public void onFinalImageSet( @Nullable Animatable animatable) { if (imageInfo != null) { mEventDispatcher.dispatchEvent( - new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD_END) + new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD) ); mEventDispatcher.dispatchEvent( - new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD) + new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD_END) ); } } @@ -204,7 +204,10 @@ public void onFinalImageSet( @Override public void onFailure(String id, Throwable throwable) { mEventDispatcher.dispatchEvent( - new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD_END) + new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_ERROR) + ); + mEventDispatcher.dispatchEvent( + new ImageLoadEvent(getId(), SystemClock.nanoTime(), ImageLoadEvent.ON_LOAD_END) ); } };