Java 类com.facebook.react.modules.core.RCTNativeAppEventEmitter 实例源码

项目:react-native-stt    文件:RNSpeechToText.java   
@ReactMethod
public void createSpeechRecognizer(final Promise promise) {
  if (reactContext == null)
    throw new IllegalArgumentException("ReactApplicationContext must be defined!");

  if (mSpeechRecognizer != null) {
    mSpeechRecognizer.destroy();
    mSpeechRecognizer = null;
  }

  if (SpeechRecognizer.isRecognitionAvailable(reactContext)) {
    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(reactContext);
    mSpeechRecognizer.setRecognitionListener(new SpeechRecognitionListener(
        this.reactContext.getJSModule(RCTNativeAppEventEmitter.class)
    ));
    promise.resolve(null);
  } else{
    promise.reject("error", "SpeechRecognizer not available");
  }
}
项目:react-native-async-storage-dev-menu-item    文件:AsyncStorageDevMenuItemModule.java   
@ReactMethod
public void initialize() {
  ReactApplication application = (ReactApplication)getReactApplicationContext()
    .getCurrentActivity()
    .getApplication();

  DevSupportManager devSupportManager = application
    .getReactNativeHost()
    .getReactInstanceManager()
    .getDevSupportManager();

  devSupportManager.addCustomDevOption("Log AsyncStorage", new DevOptionHandler() {
      @Override
      public void onOptionSelected() {
        getReactApplicationContext()
          .getJSModule(RCTNativeAppEventEmitter.class)
          .emit("LogAsyncStorage", null);
      }
  });
}
项目:RNLearn_Project1    文件:CoreModulesPackage.java   
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class));

  if (ReactBuildConfig.DEBUG) {
    jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
    jsModules.add(JSCHeapCapture.HeapCapture.class);
    jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
  }

  return jsModules;
}
项目:RNLearn_Project1    文件:CoreModulesPackage.java   
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class));

  if (ReactBuildConfig.DEBUG) {
    jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
    jsModules.add(JSCHeapCapture.HeapCapture.class);
    jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
  }

  return jsModules;
}
项目:Ironman    文件:CoreModulesPackage.java   
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class));

  if (ReactBuildConfig.DEBUG) {
    jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
    jsModules.add(JSCHeapCapture.HeapCapture.class);
    jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
  }

  return jsModules;
}
项目:react-native-android-speech-recognizer    文件:ListenerMapRecognitionListener.java   
public ListenerMapRecognitionListener(
  Set<String> enabledEvents,
  RCTNativeAppEventEmitter emitter,
  String eventPrefix
) {
  this.enabledEvents = enabledEvents;
  this.emitter = emitter;
  this.eventPrefix = eventPrefix;
}
项目:react-native-android-speech-recognizer    文件:RNAndroidSpeechRecognizerModule.java   
private void doCreateSpeechRecognizer(final Promise promise) {
  this.speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this.reactContext);
  this.speechRecognizer.setRecognitionListener(new ListenerMapRecognitionListener(
    this.enabledEvents,
    this.reactContext.getJSModule(RCTNativeAppEventEmitter.class),
    this.eventPrefix
  ));
  promise.resolve(null);
}
项目:react-native-blue-manager    文件:BleManager.java   
public void sendEvent(String eventName,
                       @Nullable WritableMap params) {
       if(reactContext!=null)
    getReactApplicationContext()
            .getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-blue-manager    文件:Peripheral.java   
private void sendEvent(String eventName, @Nullable WritableMap params) {
    if(this.reactContext==null)
        return;
    reactContext
            .getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-mpush    文件:RCTMPushReceiver.java   
@Override
    public void onReceive(Context context, Intent intent) {

        if (MPushService.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
            byte[] bytes = intent.getByteArrayExtra(MPushService.EXTRA_PUSH_MESSAGE);
            int messageId = intent.getIntExtra(MPushService.EXTRA_PUSH_MESSAGE_ID, 0);
            String message = new String(bytes, Constants.UTF_8);

//           Toast.makeText(context, "收到新的通知:" + message, Toast.LENGTH_SHORT).show();

            if (messageId > 0) MPush.I.ack(messageId);
            if (TextUtils.isEmpty(message)) return;
            reactContext.getJSModule(RCTNativeAppEventEmitter.class).emit(MPUSH_EVENT_MESSAGE, message);

        } else {
            //reactContext.getJSModule(RCTNativeAppEventEmitter.class).emit(MPUSH_EVENT, intent.getAction());
        }
        Log.d("MPush", intent.toString());
        if (MPushService.ACTION_KICK_USER.equals(intent.getAction())) {

            Toast.makeText(context, "用户被踢下线了", Toast.LENGTH_SHORT).show();
        } else if (MPushService.ACTION_BIND_USER.equals(intent.getAction())) {

            Toast.makeText(context, "绑定用户:"
                            + intent.getStringExtra(MPushService.EXTRA_USER_ID)
                            + (intent.getBooleanExtra(MPushService.EXTRA_BIND_RET, false) ? "成功" : "失败")
                    , Toast.LENGTH_SHORT).show();

        } else if (MPushService.ACTION_UNBIND_USER.equals(intent.getAction())) {
            Toast.makeText(context, "解绑用户:"
                            + (intent.getBooleanExtra(MPushService.EXTRA_BIND_RET, false)
                            ? "成功"
                            : "失败")
                    , Toast.LENGTH_SHORT).show();

        } else if (MPushService.ACTION_CONNECTIVITY_CHANGE.equals(intent.getAction())) {
            Toast.makeText(context, intent.getBooleanExtra(MPushService.EXTRA_CONNECT_STATE, false)
                            ? "MPUSH连接建立成功"
                            : "MPUSH连接断开"
                    , Toast.LENGTH_SHORT).show();
        } else if (MPushService.ACTION_HANDSHAKE_OK.equals(intent.getAction())) {
            Toast.makeText(context, "MPUSH握手成功, 心跳:" + intent.getIntExtra(MPushService.EXTRA_HEARTBEAT, 0)
                    , Toast.LENGTH_SHORT).show();
        }
    }
项目:react-native-ble-quick-sdk    文件:BleAdmin.java   
private void sendEvent(String eventName,
                       @Nullable WritableMap params) {

    //ReactApplicationContext r = getReactApplicationContext();
    //RCTNativeAppEventEmitter jm  = r.getJSModule(RCTNativeAppEventEmitter.class);
    //jm.emit(eventName, params);


    //getReactApplicationContext()
        this.reactContext.getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-stt    文件:RNSpeechToText.java   
public void getLocales() {
  Intent detailsIntent =  new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
  reactContext.sendOrderedBroadcast(
      detailsIntent, null,
      new LocalesBroadcastReceiver(this.reactContext.getJSModule(RCTNativeAppEventEmitter.class)),
      null, Activity.RESULT_OK, null, null);
}
项目:react-native-scandit    文件:SGScanditPicker.java   
@Override
public BarcodePicker createViewInstance(ThemedReactContext context) {
    // Store event dispatcher for emission of events
    eventDispatcher = context.getNativeModule(UIManagerModule.class).getEventDispatcher();

    nativeAppEventEmitter = context.getJSModule(RCTNativeAppEventEmitter.class);

    // BarcodePicker extends View
    picker = new BarcodePicker(context, scanSettings);

    // Tell picker to call our didScan method on scan
    picker.setOnScanListener(this);

    return picker;
}
项目:ReactNativeSignatureExample    文件:CoreModulesPackage.java   
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class,
      DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
}
项目:react-native-workers    文件:BaseReactPackage.java   
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Arrays.asList(
            DeviceEventManagerModule.RCTDeviceEventEmitter.class,
            JSTimersExecution.class,
            RCTEventEmitter.class,
            RCTNativeAppEventEmitter.class,
            com.facebook.react.bridge.Systrace.class,
            JSCHeapCapture.HeapCapture.class
    );
}
项目:react-native-ibeacon-android    文件:CoreModulesPackage.java   
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class,
      DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
}
项目:react-native-box-loaders    文件:CoreModulesPackage.java   
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class,
      JSCHeapCapture.HeapCapture.class,
      DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
}
项目:react-native-dmg-pingpp    文件:RnDmgPingppModule.java   
@Override
public void onActivityResult(Activity activity , final int requestCode, final int resultCode, final Intent data) {
    if (requestCode == REQUEST_CODE_PAYMENT && resultCode == activity.RESULT_OK) {
        this.handleResultData(data);
    } else {
        RCTNativeAppEventEmitter emitter = getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class);
        WritableMap map = Arguments.createMap();
        map.putString("errMsg", "返回错误");
        emitter.emit("Pingpp_Resp", map);
    }
}
项目:react-native-dmg-pingpp    文件:RnDmgPingppModule.java   
private void handleResultData(Intent data) {
    String result = data.getExtras().getString("pay_result");
    if (result != null) {
        RCTNativeAppEventEmitter emitter = getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class);
        WritableMap map = Arguments.createMap();
        map.putString("result", result);
        if (!result.equals("success")) {
            map.putInt("errCode", data.getExtras().getInt("code"));
            map.putString("errMsg", data.getExtras().getString("error_msg"));
            map.putString("extraMsg", data.getExtras().getString("extra_msg"));
        }
        emitter.emit("Pingpp_Resp", map);
    }
}
项目:react-native-fbads    文件:NativeAdManager.java   
/**
 * Helper for sending events back to Javascript.
 *
 * @param eventName
 * @param params
 */
private void sendAppEvent(String eventName, Object params) {
    ReactApplicationContext context = this.getReactApplicationContext();

    if (context == null || !context.hasActiveCatalystInstance()) {
        return;
    }

    context
            .getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-taplytics    文件:RNTaplyticsModule.java   
protected void sendEvent(
        String eventName,
        Object data) {
    reactContext
        .getJSModule(RCTNativeAppEventEmitter.class)
        .emit(eventName, data);
}
项目:react-native-nfc-manager    文件:NfcManager.java   
private void sendEvent(String eventName,
                       @Nullable WritableMap params) {
    getReactApplicationContext()
            .getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-ble-quick-sdk    文件:Peripheral.java   
private void sendEvent(String eventName, @Nullable WritableMap params) {
    reactContext
            .getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-stt    文件:LocalesBroadcastReceiver.java   
public LocalesBroadcastReceiver(RCTNativeAppEventEmitter emitter) {
  this.emitter = emitter;
}
项目:react-native-stt    文件:SpeechRecognitionListener.java   
public SpeechRecognitionListener(RCTNativeAppEventEmitter emitter) {
  this.emitter = emitter;
}
项目:react-native-ble-manager    文件:BleManager.java   
public void sendEvent(String eventName,
                      @Nullable WritableMap params) {
    getReactApplicationContext()
            .getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-ble-manager    文件:Peripheral.java   
private void sendEvent(String eventName, @Nullable WritableMap params) {
    reactContext
            .getJSModule(RCTNativeAppEventEmitter.class)
            .emit(eventName, params);
}
项目:react-native-bluetooth-io    文件:BluetoothIOModule.java   
private void sendEvent(String eventName,
@Nullable WritableMap params) {
  getReactApplicationContext()
  .getJSModule(RCTNativeAppEventEmitter.class)
  .emit(eventName, params);
}
项目:react-native-bluetooth-io    文件:BluetoothIOModule.java   
private void sendEvent(String eventName) {
  getReactApplicationContext()
  .getJSModule(RCTNativeAppEventEmitter.class)
  .emit(eventName, null);
}
项目:react-native-volume    文件:SettingsContentObserver.java   
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
    reactContext
        .getJSModule(RCTNativeAppEventEmitter.class)
        .emit(eventName, params);
}
项目:react-native-background-geolocation    文件:RNBackgroundGeolocationModule.java   
@Override
public void onPowerSaveChange(Boolean isPowerSaveMode) {
    getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(BackgroundGeolocation.EVENT_POWERSAVECHANGE, isPowerSaveMode);
}
项目:react-native-background-geolocation    文件:RNBackgroundGeolocationModule.java   
private void sendEvent(String eventName, WritableMap params) {
    getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(eventName, params);
}
项目:react-native-background-geolocation    文件:RNBackgroundGeolocationModule.java   
private void sendEvent(String eventName, String result) {
    getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(eventName, result);
}