Example usage for com.facebook.react.views.image ImageLoadEvent ON_LOAD_START

List of usage examples for com.facebook.react.views.image ImageLoadEvent ON_LOAD_START

Introduction

In this page you can find the example usage for com.facebook.react.views.image ImageLoadEvent ON_LOAD_START.

Prototype

int ON_LOAD_START

To view the source code for com.facebook.react.views.image ImageLoadEvent ON_LOAD_START.

Click Source Link

Usage

From source file:com.reactImageWand.RNImageWand.java

License:Open Source License

public void setShouldNotifyLoadEvents(boolean shouldNotify) {
    if (!shouldNotify) {
        mControllerListener = null;/*from ww w  .  ja  va  2  s .  co  m*/
    } else {
        final EventDispatcher mEventDispatcher = ((ReactContext) getContext())
                .getNativeModule(UIManagerModule.class).getEventDispatcher();

        mControllerListener = new BaseControllerListener<ImageInfo>() {
            @Override
            public void onSubmit(String id, Object callerContext) {
                mEventDispatcher.dispatchEvent(
                        new ImageLoadEvent(getId(), SystemClock.uptimeMillis(), ImageLoadEvent.ON_LOAD_START));
            }

            @Override
            public void onFinalImageSet(String id, @Nullable final ImageInfo imageInfo,
                    @Nullable Animatable animatable) {
                if (imageInfo != null) {
                    onImageInfo(imageInfo.getWidth(), imageInfo.getHeight());
                    mEventDispatcher.dispatchEvent(new ImageLoadEvent(getId(), SystemClock.uptimeMillis(),
                            ImageLoadEvent.ON_LOAD_END));
                    mEventDispatcher.dispatchEvent(
                            new ImageLoadEvent(getId(), SystemClock.uptimeMillis(), ImageLoadEvent.ON_LOAD));
                }
            }

            @Override
            public void onFailure(String id, Throwable throwable) {
                mEventDispatcher.dispatchEvent(
                        new ImageLoadEvent(getId(), SystemClock.uptimeMillis(), ImageLoadEvent.ON_LOAD_END));
            }
        };
    }

    mIsDirty = true;
}