com.facebook.react.modules.core.DeviceEventManagerModule Java Examples
The following examples show how to use
com.facebook.react.modules.core.DeviceEventManagerModule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmsReceiver.java From react-native-android-sms-listener with MIT License | 6 votes |
private void receiveMessage(SmsMessage message) { if (mContext == null) { return; } if (! mContext.hasActiveCatalystInstance()) { return; } Log.d( SmsListenerPackage.TAG, String.format("%s: %s", message.getOriginatingAddress(), message.getMessageBody()) ); WritableNativeMap receivedMessage = new WritableNativeMap(); receivedMessage.putString("originatingAddress", message.getOriginatingAddress()); receivedMessage.putString("body", message.getMessageBody()); mContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(EVENT, receivedMessage); }
Example #2
Source File: OrientationModule.java From react-native-orientation-locker with MIT License | 6 votes |
@ReactMethod public void lockToLandscape() { final Activity activity = getCurrentActivity(); if (activity == null) return; activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); isLocked = true; // force send an UI orientation event lastOrientationValue = "LANDSCAPE-LEFT"; WritableMap params = Arguments.createMap(); params.putString("orientation", lastOrientationValue); if (ctx.hasActiveCatalystInstance()) { ctx .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("orientationDidChange", params); } // send a locked event WritableMap lockParams = Arguments.createMap(); lockParams.putString("orientation", lastOrientationValue); if (ctx.hasActiveCatalystInstance()) { ctx .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("lockDidChange", lockParams); } }
Example #3
Source File: RNTusClientModule.java From react-native-tus-client with MIT License | 6 votes |
protected void makeAttempt() throws ProtocolException, IOException { uploader = client.resumeOrCreateUpload(upload); uploader.setChunkSize(1024); uploader.setRequestPayloadSize(10 * 1024 * 1024); do { long totalBytes = upload.getSize(); long bytesUploaded = uploader.getOffset(); WritableMap params = Arguments.createMap(); params.putString("uploadId", uploadId); params.putDouble("bytesWritten", bytesUploaded); params.putDouble("bytesTotal", totalBytes); reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(ON_PROGRESS, params); }while(uploader.uploadChunk() > -1 && !shouldFinish); uploader.finish(); }
Example #4
Source File: NativeAnimatedModule.java From react-native-GPay with MIT License | 6 votes |
@ReactMethod public void startListeningToAnimatedNodeValue(final int tag) { final AnimatedNodeValueListener listener = new AnimatedNodeValueListener() { public void onValueUpdate(double value) { WritableMap onAnimatedValueData = Arguments.createMap(); onAnimatedValueData.putInt("tag", tag); onAnimatedValueData.putDouble("value", value); getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("onAnimatedValueUpdate", onAnimatedValueData); } }; mOperations.add(new UIThreadOperation() { @Override public void execute(NativeAnimatedNodesManager animatedNodesManager) { animatedNodesManager.startListeningToAnimatedNodeValue(tag, listener); } }); }
Example #5
Source File: OrientationModule.java From react-native-orientation-locker with MIT License | 6 votes |
@ReactMethod public void lockToLandscapeLeft() { final Activity activity = getCurrentActivity(); if (activity == null) return; activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); isLocked = true; // force send an UI orientation event lastOrientationValue = "LANDSCAPE-LEFT"; WritableMap params = Arguments.createMap(); params.putString("orientation", lastOrientationValue); if (ctx.hasActiveCatalystInstance()) { ctx .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("orientationDidChange", params); } // send a locked event WritableMap lockParams = Arguments.createMap(); lockParams.putString("orientation", lastOrientationValue); if (ctx.hasActiveCatalystInstance()) { ctx .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("lockDidChange", lockParams); } }
Example #6
Source File: OrientationModule.java From react-native-orientation-locker with MIT License | 6 votes |
@ReactMethod public void lockToLandscapeRight() { final Activity activity = getCurrentActivity(); if (activity == null) return; activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); isLocked = true; // force send an UI orientation event lastOrientationValue = "LANDSCAPE-RIGHT"; WritableMap params = Arguments.createMap(); params.putString("orientation", lastOrientationValue); if (ctx.hasActiveCatalystInstance()) { ctx .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("orientationDidChange", params); } // send a locked event WritableMap lockParams = Arguments.createMap(); lockParams.putString("orientation", lastOrientationValue); if (ctx.hasActiveCatalystInstance()) { ctx .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("lockDidChange", lockParams); } }
Example #7
Source File: UdpSockets.java From react-native-udp with MIT License | 5 votes |
/** * Notifies the javascript layer upon data receipt. */ @Override public void didReceiveData(final UdpSocketClient socket, final String data, final String host, final int port) { new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) { @Override protected void doInBackgroundGuarded(Void... params) { int clientID = -1; for(int i = 0; i < mClients.size(); i++) { clientID = mClients.keyAt(i); // get the object by the key. if (socket.equals(mClients.get(clientID))) { break; } } if (clientID == -1) { return; } WritableMap eventParams = Arguments.createMap(); eventParams.putString("data", data); eventParams.putString("address", host); eventParams.putInt("port", port); ReactContext reactContext = UdpSockets.this.getReactApplicationContext(); reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("udp-" + clientID + "-data", eventParams); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
Example #8
Source File: StepSensor.java From react-native-google-fit with MIT License | 5 votes |
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); }
Example #9
Source File: RNGoogleSigninButtonViewManager.java From google-signin with MIT License | 5 votes |
@Override protected SignInButton createViewInstance(final ThemedReactContext reactContext) { SignInButton button = new SignInButton(reactContext); button.setSize(SignInButton.SIZE_STANDARD); button.setColorScheme(SignInButton.COLOR_AUTO); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("RNGoogleSigninButtonClicked", null); } }); return button; }
Example #10
Source File: GoogleFitManager.java From react-native-google-fit with MIT License | 5 votes |
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); }
Example #11
Source File: StepHistory.java From react-native-google-fit with MIT License | 5 votes |
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableArray params) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); }
Example #12
Source File: ReactInstanceManager.java From react-native-GPay with MIT License | 5 votes |
/** * This method will give JS the opportunity to consume the back button event. If JS does not * consume the event, mDefaultBackButtonImpl will be invoked at the end of the round trip to JS. */ public void onBackPressed() { UiThreadUtil.assertOnUiThread(); ReactContext reactContext = mCurrentReactContext; if (reactContext == null) { // Invoke without round trip to JS. FLog.w(ReactConstants.TAG, "Instance detached from instance manager"); invokeDefaultOnBackPressed(); } else { DeviceEventManagerModule deviceEventManagerModule = reactContext.getNativeModule(DeviceEventManagerModule.class); deviceEventManagerModule.emitHardwareBackPressed(); } }
Example #13
Source File: AccessibilityInfoModule.java From react-native-GPay with MIT License | 5 votes |
private void updateAndSendChangeEvent(boolean enabled) { if (mEnabled != enabled) { mEnabled = enabled; getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(EVENT_NAME, mEnabled); } }
Example #14
Source File: FusedLocationModule.java From react-native-fused-location with MIT License | 5 votes |
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) { if (reactContext.hasActiveCatalystInstance()) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); } else { Log.d(TAG, "Waiting for Catalyst Instance..."); } }
Example #15
Source File: OBD2Handler.java From react-native-obd2 with MIT License | 5 votes |
private void sendEvent(String eventName, @Nullable WritableMap params) { try { mReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params); } catch (RuntimeException e) { Log.e("OBD2Handler", "Error to send an event to jsModule"); } }
Example #16
Source File: MyTJPlacementListener.java From react-native-tapjoy with MIT License | 5 votes |
private void fireEvent(String eventName, WritableMap resp) { if (reactContext.hasActiveCatalystInstance()) { reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, resp); } else { Log.d(TAG, "Waiting for CatalystInstance before sending event."); } }
Example #17
Source File: RNDeviceModule.java From react-native-device-info with MIT License | 5 votes |
private void sendEvent(ReactContext reactContext, String eventName, @Nullable Object data) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, data); }
Example #18
Source File: FlurryModule.java From react-native-flurry-sdk with Apache License 2.0 | 5 votes |
private static void sendEvent(EventType type, String token) { WritableMap params = Arguments.createMap(); params.putString("Type", type.getName()); params.putString("Token", token); sReactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(FLURRY_MESSAGING_EVENT, params); }
Example #19
Source File: RealtimeMessagingAndroid.java From RCTRealtimeMessagingAndroid with MIT License | 5 votes |
private void sendEvent(ReactContext reactContext, String eventName, @Nullable Object params) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); }
Example #20
Source File: EventEmitter.java From react-native-navigation with MIT License | 5 votes |
private void emit(String eventName, WritableMap data) { if (reactContext == null) { Log.e("RNN", "Could not send event " + eventName + ". React context is null!"); return; } RCTDeviceEventEmitter emitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class); emitter.emit(eventName, data); }
Example #21
Source File: AuroraIMUIModule.java From aurora-imui with MIT License | 5 votes |
@Subscribe(threadMode = ThreadMode.MAIN) public void onEvent(GetTextEvent event) { if (event.getAction().equals(GET_INPUT_TEXT_EVENT)) { getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(GET_INPUT_TEXT_EVENT, event.getText()); } }
Example #22
Source File: StepCounter.java From react-native-google-fit with MIT License | 5 votes |
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); }
Example #23
Source File: BackgroundTimerModule.java From react-native-background-timer with MIT License | 5 votes |
@ReactMethod public void setTimeout(final int id, final int timeout) { Handler handler = new Handler(); handler.postDelayed(new Runnable(){ @Override public void run(){ if (getReactApplicationContext().hasActiveCatalystInstance()) { getReactApplicationContext() .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("backgroundTimer.timeout", id); } } }, timeout); }
Example #24
Source File: RNWorkersModule.java From react-native-workers with Apache License 2.0 | 5 votes |
@ReactMethod public void sendMessageToWorker(final int port, final String message) { final ReactApplicationContext context = RNWorkersManager.getInstance().getWorkerReactContext(port); if (context == null) { return; } context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("RNWorkers", message); }
Example #25
Source File: RNZipArchiveModule.java From react-native-zip-archive with MIT License | 5 votes |
protected void updateProgress(long extractedBytes, long totalSize, String zipFilePath) { // Ensure progress can't overflow 1 double progress = Math.min((double) extractedBytes / (double) totalSize, 1); Log.d(TAG, String.format("updateProgress: %.0f%%", progress * 100)); WritableMap map = Arguments.createMap(); map.putString(EVENT_KEY_FILENAME, zipFilePath); map.putDouble(EVENT_KEY_PROGRESS, progress); getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(PROGRESS_EVENT_NAME, map); }
Example #26
Source File: RNCameraComponentView.java From react-native-camera-android with MIT License | 5 votes |
@Override public void returnPictureTakenResult(String resultType, String resultMessage) { WritableMap params = Arguments.createMap(); params.putString("type", resultType); params.putString("message", resultMessage); mContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("cameraResult", params); }
Example #27
Source File: EventManager.java From react-native-twilio-programmable-voice with MIT License | 5 votes |
public void sendEvent(String eventName, @Nullable WritableMap params) { if (BuildConfig.DEBUG) { Log.d(TAG, "sendEvent "+eventName+" params "+params); } if (mContext.hasActiveCatalystInstance()) { mContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); } else { if (BuildConfig.DEBUG) { Log.d(TAG, "failed Catalyst instance not active"); } } }
Example #28
Source File: OTSessionManager.java From opentok-react-native with MIT License | 5 votes |
private void sendEventWithString(ReactContext reactContext, String eventName, String eventString) { if (Utils.contains(jsEvents, eventName) || Utils.contains(componentEvents, eventName)) { reactContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, eventString); } }
Example #29
Source File: RNFileViewerModule.java From react-native-file-viewer with MIT License | 5 votes |
private void sendEvent(String eventName, Integer currentId, String errorMessage) { WritableMap params = Arguments.createMap(); params.putInt("id", currentId); if(errorMessage != null) { params.putString("error", errorMessage); } reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(eventName, params); }
Example #30
Source File: FlurryModule.java From react-native-flurry-sdk with Apache License 2.0 | 5 votes |
private void sendEvent(EventType type, String key, boolean value) { WritableMap params = Arguments.createMap(); params.putString("Type", type.getName()); if (key != null) { params.putBoolean(key, value); } sReactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(FLURRY_CONFIG_EVENT, params); }