Skip to content

Commit

Permalink
Improves react image loading handlers to mimic iOS behavior
Browse files Browse the repository at this point in the history
Reviewed By: vjeux

Differential Revision: D3283011

fbshipit-source-id: acb04f8b2ccbab99a59040a7ca70aa46cbf73faa
  • Loading branch information
olinotteghem authored and Facebook Github Bot 5 committed May 10, 2016
1 parent c1f0ce2 commit 68b2f49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,21 @@ 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)
);
}
}

@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)
);
}
};
Expand Down

0 comments on commit 68b2f49

Please sign in to comment.