mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 09:29:07 +08:00
Improves RCTImage loading handlers to mimic iOS behavior
Summary: This is a port of D3283011 to Nodes. Reviewed By: sahrens Differential Revision: D3290662
This commit is contained in:
@@ -174,8 +174,8 @@ import com.facebook.react.views.image.ReactImageView;
|
||||
@Nullable Object imageInfo,
|
||||
@Nullable Animatable animatable) {
|
||||
if (mCallback != null && mReactTag != 0) {
|
||||
mCallback.dispatchImageLoadEvent(mReactTag, ImageLoadEvent.ON_LOAD_END);
|
||||
mCallback.dispatchImageLoadEvent(mReactTag, ImageLoadEvent.ON_LOAD);
|
||||
mCallback.dispatchImageLoadEvent(mReactTag, ImageLoadEvent.ON_LOAD_END);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ import com.facebook.react.views.image.ReactImageView;
|
||||
@Override
|
||||
public void onFailure(String id, Throwable throwable) {
|
||||
if (mCallback != null && mReactTag != 0) {
|
||||
mCallback.dispatchImageLoadEvent(mReactTag, ImageLoadEvent.ON_ERROR);
|
||||
mCallback.dispatchImageLoadEvent(mReactTag, ImageLoadEvent.ON_LOAD_END);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ import com.facebook.react.views.image.ImageLoadEvent;
|
||||
|
||||
BitmapUpdateListener listener = Assertions.assumeNotNull(mBitmapUpdateListener);
|
||||
listener.onBitmapReady(bitmap);
|
||||
listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_END);
|
||||
listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD);
|
||||
listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_END);
|
||||
} finally {
|
||||
dataSource.close();
|
||||
}
|
||||
@@ -165,6 +165,7 @@ import com.facebook.react.views.image.ImageLoadEvent;
|
||||
@Override
|
||||
public void onFailure(DataSource<CloseableReference<CloseableImage>> dataSource) {
|
||||
if (mDataSource == dataSource) {
|
||||
Assertions.assumeNotNull(mBitmapUpdateListener).onImageLoadEvent(ImageLoadEvent.ON_ERROR);
|
||||
Assertions.assumeNotNull(mBitmapUpdateListener).onImageLoadEvent(ImageLoadEvent.ON_LOAD_END);
|
||||
mDataSource = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user