Improves react image loading handlers to mimic iOS behavior

Reviewed By: vjeux

Differential Revision: D3283011

fbshipit-source-id: acb04f8b2ccbab99a59040a7ca70aa46cbf73faa
This commit is contained in:
Olivier Notteghem 2016-05-10 14:16:26 -07:00 committed by Facebook Github Bot 5
parent c1f0ce283c
commit 68b2f49a31
2 changed files with 7 additions and 4 deletions

View File

@ -26,7 +26,7 @@ public class ImageLoadEvent extends Event<ImageLoadEvent> {
@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;

View File

@ -193,10 +193,10 @@ public class ReactImageView extends GenericDraweeView {
@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 class ReactImageView extends GenericDraweeView {
@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)
);
}
};