List of usage examples for com.facebook.react.uimanager.events EventDispatcher dispatchEvent
public void dispatchEvent(Event event)
From source file:cn.chronos.image.ImageAndroidView.java
License:Open Source License
public void setShouldNotifyLoadEvents(boolean shouldNotify) { if (!shouldNotify) { mControllerListener = null;//from www. j a va 2 s .com } 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 ImageAndroidLoadEvent(getId(), SystemClock.uptimeMillis(), ImageAndroidLoadEvent.ON_LOAD_START)); } @Override public void onFinalImageSet(String id, @Nullable final ImageInfo imageInfo, @Nullable Animatable animatable) { if (imageInfo != null) { mEventDispatcher.dispatchEvent(new ImageAndroidLoadEvent(getId(), SystemClock.uptimeMillis(), ImageAndroidLoadEvent.ON_LOAD_END)); // ?onInfo mEventDispatcher.dispatchEvent(new ImageAndroidLoadEvent(getId(), SystemClock.uptimeMillis(), ImageAndroidLoadEvent.ON_LOAD, imageInfo.getWidth(), imageInfo.getHeight())); } } @Override public void onFailure(String id, Throwable throwable) { mEventDispatcher.dispatchEvent(new ImageAndroidLoadEvent(getId(), SystemClock.uptimeMillis(), ImageAndroidLoadEvent.ON_LOAD_END)); } }; } mIsDirty = true; }
From source file:com.blockablewebview.BlockableWebViewManager.java
License:Open Source License
private static void dispatchEvent(WebView webView, Event event) { ReactContext reactContext = (ReactContext) webView.getContext(); EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); eventDispatcher.dispatchEvent(event); }
From source file:com.horcrux.svg.RNSVGSvgView.java
License:Open Source License
public void handleTouchEvent(MotionEvent ev, EventDispatcher eventDispatcher) { int action = ev.getAction() & MotionEvent.ACTION_MASK; if (action == MotionEvent.ACTION_DOWN) { eventDispatcher.dispatchEvent(TouchEvent.obtain(mTargetTag, SystemClock.nanoTime(), TouchEventType.START, ev, ev.getX(), ev.getX(), mTouchEventCoalescingKeyHelper)); } else if (mTargetTag == -1) { // All the subsequent action types are expected to be called after ACTION_DOWN thus target // is supposed to be set for them. Log.e("error", "Unexpected state: received touch event but didn't get starting ACTION_DOWN for this " + "gesture before"); } else if (action == MotionEvent.ACTION_UP) { // End of the gesture. We reset target tag to -1 and expect no further event associated with // this gesture. eventDispatcher.dispatchEvent(TouchEvent.obtain(mTargetTag, SystemClock.nanoTime(), TouchEventType.END, ev, ev.getX(), ev.getY(), mTouchEventCoalescingKeyHelper)); mTargetTag = -1;/*from www.java 2s. c om*/ } else if (action == MotionEvent.ACTION_MOVE) { // Update pointer position for current gesture eventDispatcher.dispatchEvent(TouchEvent.obtain(mTargetTag, SystemClock.nanoTime(), TouchEventType.MOVE, ev, ev.getX(), ev.getY(), mTouchEventCoalescingKeyHelper)); } else if (action == MotionEvent.ACTION_POINTER_DOWN) { // New pointer goes down, this can only happen after ACTION_DOWN is sent for the first pointer eventDispatcher.dispatchEvent(TouchEvent.obtain(mTargetTag, SystemClock.nanoTime(), TouchEventType.START, ev, ev.getX(), ev.getY(), mTouchEventCoalescingKeyHelper)); } else if (action == MotionEvent.ACTION_POINTER_UP) { // Exactly onw of the pointers goes up eventDispatcher.dispatchEvent(TouchEvent.obtain(mTargetTag, SystemClock.nanoTime(), TouchEventType.END, ev, ev.getX(), ev.getY(), mTouchEventCoalescingKeyHelper)); } else if (action == MotionEvent.ACTION_CANCEL) { dispatchCancelEvent(ev, eventDispatcher); mTargetTag = -1; } else { Log.w("IGNORE", "Warning : touch event was ignored. Action=" + action + " Target=" + mTargetTag); } }
From source file:com.lightappbuilder.lab4.lablibrary.rnviews.webview.ReactWebViewManager.java
License:Open Source License
static void dispatchEvent(WebView webView, Event event) { ReactContext reactContext = (ReactContext) webView.getContext(); EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); eventDispatcher.dispatchEvent(event); }
From source file:com.reactImageWand.RNImageWand.java
License:Open Source License
public void setShouldNotifyLoadEvents(boolean shouldNotify) { if (!shouldNotify) { mControllerListener = null;/*from w w w .j a v a 2 s . c o 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; }
From source file:fr.bamlab.textinput.ReactTextInputManager.java
License:Open Source License
@Override protected void addEventEmitters(final ThemedReactContext reactContext, final ReactEditText editText) { editText.addTextChangedListener(new ReactTextInputTextWatcher(reactContext, editText)); editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class) .getEventDispatcher(); if (hasFocus) { eventDispatcher.dispatchEvent( new ReactTextInputFocusEvent(editText.getId(), SystemClock.uptimeMillis())); } else { eventDispatcher.dispatchEvent( new ReactTextInputBlurEvent(editText.getId(), SystemClock.uptimeMillis())); eventDispatcher.dispatchEvent(new ReactTextInputEndEditingEvent(editText.getId(), SystemClock.uptimeMillis(), editText.getText().toString())); }//from www .j a v a 2s .c o m } }); editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent keyEvent) { // Any 'Enter' action will do if ((actionId & EditorInfo.IME_MASK_ACTION) > 0 || actionId == EditorInfo.IME_NULL) { EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class) .getEventDispatcher(); eventDispatcher.dispatchEvent(new ReactTextInputSubmitEditingEvent(editText.getId(), SystemClock.uptimeMillis(), editText.getText().toString())); } return false; } }); }