Java 类com.facebook.react.bridge.NativeModule 实例源码

项目:RNLearn_Project1    文件:ModuleHolder.java   
private NativeModule create() {
  SoftAssertions.assertCondition(mModule == null, "Creating an already created module.");
  ReactMarker.logMarker(CREATE_MODULE_START, mName);
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule")
    .arg("name", mName)
    .flush();
  NativeModule module = assertNotNull(mProvider).get();
  mProvider = null;
  if (mInitializeNeeded) {
    doInitialize(module);
    mInitializeNeeded = false;
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(CREATE_MODULE_END);
  return module;
}
项目:react-native-threads    文件:ThreadBaseReactPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext catalystApplicationContext) {
    return Arrays.<NativeModule>asList(
            // Core list
            new AndroidInfoModule(),
            new ExceptionsManagerModule(reactInstanceManager.getDevSupportManager()),
            new AppStateModule(catalystApplicationContext),
            new Timing(catalystApplicationContext, reactInstanceManager.getDevSupportManager()),
            new UIManagerStubModule(catalystApplicationContext),
            new SourceCodeModule(catalystApplicationContext),
            new JSCHeapCapture(catalystApplicationContext),

            // Main list
            new AsyncStorageModule(catalystApplicationContext),
            new IntentModule(catalystApplicationContext),
            new LocationModule(catalystApplicationContext),
            new NetworkingModule(catalystApplicationContext),
            new NetInfoModule(catalystApplicationContext),
            new VibrationModule(catalystApplicationContext),
            new WebSocketModule(catalystApplicationContext),
            new ThreadSelfModule(catalystApplicationContext)
    );
}
项目:RNLearn_Project1    文件:CompositeReactPackage.java   
/**
 * {@inheritDoc}
 */
@Override
public List<NativeModule> createNativeModules(
    ReactApplicationContext reactContext,
    ReactInstanceManager reactInstanceManager) {
  final Map<String, NativeModule> moduleMap = new HashMap<>();
  for (ReactPackage reactPackage: mChildReactPackages) {
    List<NativeModule> nativeModules;
    if (reactPackage instanceof ReactInstancePackage) {
      ReactInstancePackage reactInstancePackage = (ReactInstancePackage) reactPackage;
      nativeModules = reactInstancePackage.createNativeModules(
          reactContext,
          reactInstanceManager);
    } else {
      nativeModules = reactPackage.createNativeModules(reactContext);
    }
    for (NativeModule nativeModule: nativeModules) {
      moduleMap.put(nativeModule.getName(), nativeModule);
    }
  }
  return new ArrayList(moduleMap.values());
}
项目:react-native-sweet-alert    文件:RNSweetAlertPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();
  modules.add(new RNSweetAlertModule(reactContext));

  return modules;
}
项目:React-Native-Music-Player    文件:MusicPlayerModulePackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new MusicPlayerModule(reactContext));
    return modules;
}
项目:react-native-webrtc    文件:WebRTCModulePackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new WebRTCModule(reactContext));
    return modules;
}
项目:react-native-stt    文件:RNSpeechToTextPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new RNSpeechToText(reactApplicationContext));

  return modules;
}
项目:react-native-download-manager    文件:DownloadFilePackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new DownloadFileManager(reactContext));

    return modules;
}
项目:RNLearn_Project1    文件:ModuleHolder.java   
public ModuleHolder(NativeModule nativeModule) {
  mName = nativeModule.getName();
  mCanOverrideExistingModule = nativeModule.canOverrideExistingModule();
  mSupportsWebWorkers = nativeModule.supportsWebWorkers();
  mHasConstants = true;
  mModule = nativeModule;
}
项目:react-native-nfc-manager    文件:NfcManagerPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new NfcManager(reactApplicationContext));
    return modules;
}
项目:nfc-react-native-simple    文件:NfcReactNativeSimplePackage.java   
/**
 * @param reactContext react application context that can be used to create modules
 * @return list of native modules to register with the newly created catalyst instance
 */
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new NfcReactNativeSimpleModule(reactContext));

    return modules;
}
项目:react-native-system-setting    文件:SystemSettingPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new SystemSetting(reactContext));

    return modules;
}
项目:react-native-background-task    文件:BackgroundTaskPackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new BackgroundTaskModule(reactContext));

    return modules;
}
项目:RNLearn_Project1    文件:ReactPackage.java   
@Override
public List<NativeModule> createNativeModules(
    ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();
  modules.add(new SomeExampleModule(reactContext));
  return modules;
}
项目:RNLearn_Project1    文件:NativeModuleRegistry.java   
Collection<JavaModuleWrapper> getJavaModules(
    JSInstance jsInstance) {
  ArrayList<JavaModuleWrapper> javaModules = new ArrayList<>();
  for (Map.Entry<Class<? extends NativeModule>, ModuleHolder> entry : mModules.entrySet()) {
    Class<?> type = entry.getKey();
    if (!CxxModuleWrapper.class.isAssignableFrom(type)) {
      javaModules.add(new JavaModuleWrapper(jsInstance, entry.getValue()));
    }
  }
  return javaModules;
}
项目:react-native-caller-id-android    文件:CallerIDReactPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new AddPermissions(reactContext));
    modules.add(new UsersDB(reactContext));

    return modules;
}
项目:react-native-alert    文件:PLPAlertPackage.java   
@Override
public List<NativeModule> createNativeModules(
                            ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new DialogModule(reactContext));

  return modules;
}
项目:react-native-exit-app    文件:RNExitAppPackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new RNExitAppModule(reactContext));

    return modules;
}
项目:RNLearn_Project1    文件:ReactTestHelper.java   
@Override
public ReactInstanceEasyBuilder addNativeModule(NativeModule nativeModule) {
  if (mNativeModuleRegistryBuilder == null) {
    mNativeModuleRegistryBuilder = new NativeModuleRegistryBuilder(
      (ReactApplicationContext) mContext,
      null,
      false);
  }
  mNativeModuleRegistryBuilder.addNativeModule(nativeModule);
  return this;
}
项目:react-native-key-value-storage    文件:KeyValueStoragePackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new KeyValueStorageModule(reactContext));

    return modules;
}
项目:react-native-threads    文件:ReactContextBuilder.java   
private void addNativeModules(ReactApplicationContext reactContext, NativeModuleRegistryBuilder nativeRegistryBuilder) {
    for (int i = 0; i < reactPackages.size(); i++) {
        ReactPackage reactPackage = reactPackages.get(i);
        for (NativeModule nativeModule : reactPackage.createNativeModules(reactContext)) {
            nativeRegistryBuilder.addNativeModule(nativeModule);
        }
    }
}
项目:RNLearn_Project1    文件:JavaModuleWrapper.java   
public JavaModuleWrapper(JSInstance jsInstance, Class<? extends NativeModule> moduleClass, ModuleHolder moduleHolder) {
  mJSInstance = jsInstance;
  mModuleHolder = moduleHolder;
  mModuleClass = moduleClass;
  mMethods = new ArrayList<>();
  mDescs = new ArrayList();
}
项目:onfido-sdk-react-native-sample-app    文件:AppPackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new OnfidoSDK(reactContext));

    return modules;
}
项目:RNLearn_Project1    文件:CompositeReactPackageTest.java   
@Test
public void testThatCompositeReturnsASumOfNativeModules() {
  // Given
  CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2);

  NativeModule moduleNo1 = mock(NativeModule.class);
  when(moduleNo1.getName()).thenReturn("ModuleNo1");

  // module2 and module3 will share same name, composite should return only the latter one
  final String sameModuleName = "SameModuleName";

  NativeModule moduleNo2 = mock(NativeModule.class);
  when(moduleNo2.getName()).thenReturn(sameModuleName);

  NativeModule moduleNo3 = mock(NativeModule.class);
  when(moduleNo3.getName()).thenReturn(sameModuleName);

  NativeModule moduleNo4 = mock(NativeModule.class);
  when(moduleNo4.getName()).thenReturn("ModuleNo4");

  when(packageNo1.createNativeModules(reactContext)).thenReturn(
      Arrays.asList(new NativeModule[]{moduleNo1, moduleNo2}));

  when(packageNo2.createNativeModules(reactContext)).thenReturn(
      Arrays.asList(new NativeModule[]{moduleNo3, moduleNo4}));

  // When
  List<NativeModule> compositeModules = composite.createNativeModules(reactContext);

  // Then

  // Wrapping lists into sets to be order-independent.
  // Note that there should be no module2 returned.
  Set<NativeModule> expected = new HashSet<>(
      Arrays.asList(new NativeModule[]{moduleNo1, moduleNo3, moduleNo4}));
  Set<NativeModule> actual = new HashSet<>(compositeModules);

  assertEquals(expected, actual);
}
项目:react-native-growingio    文件:GrowingRnPackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new GrowingIOModule(reactContext));
    return modules;
}
项目:RNLearn_Project1    文件:NativeModuleRegistry.java   
Collection<JavaModuleWrapper> getJavaModules(
    JSInstance jsInstance) {
  ArrayList<JavaModuleWrapper> javaModules = new ArrayList<>();
  for (Map.Entry<Class<? extends NativeModule>, ModuleHolder> entry : mModules.entrySet()) {
    Class<? extends NativeModule> type = entry.getKey();
    if (!CxxModuleWrapperBase.class.isAssignableFrom(type)) {
      javaModules.add(new JavaModuleWrapper(jsInstance, type, entry.getValue()));
    }
  }
  return javaModules;
}
项目:RNLearn_Project1    文件:NativeModuleRegistryBuilder.java   
public NativeModuleRegistry build() {
  ArrayList<ModuleHolder> batchCompleteListenerModules = new ArrayList<>();
  for (Map.Entry<Class<? extends NativeModule>, ModuleHolder> entry : mModules.entrySet()) {
    if (OnBatchCompleteListener.class.isAssignableFrom(entry.getKey())) {
      batchCompleteListenerModules.add(entry.getValue());
    }
  }

  return new NativeModuleRegistry(
    mReactApplicationContext,
    mModules,
    batchCompleteListenerModules);
}
项目:rn-crash-reporter    文件:RNCrashReporterModule.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {

    return Arrays.<NativeModule>asList(
        new RNCrashReporter(reactContext, currentActivity)
    );
}
项目:react-native-call-log    文件:CallLogPackage.java   
@Override
public List<NativeModule> createNativeModules(
                            ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new CallLogModule(reactContext));

  return modules;
}
项目:react-native-sunmi-inner-printer    文件:SunmiInnerPrinterPackage.java   
@Override
public List<NativeModule> createNativeModules(
                            ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new SunmiInnerPrinterModule(reactContext));

  return modules;
}
项目:react-native-call-events    文件:ReactNativeCallEventsPackageTest.java   
@Test
public void testCreateNativeModules() throws Exception {
    ReactNativeCallEventsPackage instance = new ReactNativeCallEventsPackage();
    List<NativeModule> results = instance.createNativeModules(reactContext);
    ReactNativeCallEventsModule result = (ReactNativeCallEventsModule) results.get(0);
    assertThat(result, not(equalTo(null)));
}
项目:react-native-screenshot-detect    文件:ScreenShotDetectPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {

    List<NativeModule> modules = new ArrayList<>();
    modules.add(new ScreenShotDetectModule(reactContext));
    return modules;
}
项目:RNLearn_Project1    文件:ReactTestHelper.java   
@Override
public ReactInstanceEasyBuilder addNativeModule(NativeModule nativeModule) {
  if (mNativeModuleRegistryBuilder == null) {
    mNativeModuleRegistryBuilder = new NativeModuleRegistryBuilder(
      (ReactApplicationContext) mContext,
      null,
      false);
  }
  mNativeModuleRegistryBuilder.addNativeModule(nativeModule);
  return this;
}
项目:react-native-icon-badge    文件:RNIconBadge.java   
@Override
public List<NativeModule> createNativeModules(
                            ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new RNIconBadgeModule(reactContext));

  return modules;
}
项目:RNLearn_Project1    文件:ModuleHolder.java   
private void doInitialize(NativeModule module) {
  SystraceMessage.Builder section =
    SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "initialize");
  if (module instanceof CxxModuleWrapper) {
    section.arg("className", module.getClass().getSimpleName());
  } else {
    section.arg("name", mName);
  }
  section.flush();
  ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_START, mName);
  module.initialize();
  ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END);
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
项目:RNLearn_Project1    文件:NativeModuleRegistry.java   
public NativeModuleRegistry(
  ReactApplicationContext reactApplicationContext,
  Map<Class<? extends NativeModule>, ModuleHolder> modules,
  ArrayList<ModuleHolder> batchCompleteListenerModules) {
  mReactApplicationContext = reactApplicationContext;
  mModules = modules;
  mBatchCompleteListenerModules = batchCompleteListenerModules;
}
项目:react-native-async-storage-dev-menu-item    文件:AsyncStorageDevMenuItemPackage.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new AsyncStorageDevMenuItemModule(reactContext));

  return modules;
}
项目:RNNavitiaSDK    文件:RNNavitiaSDKPackage.java   
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new RNNavitiaSDK(reactContext));
    return modules;
}
项目:react-native-forward-calls    文件:RNForwardCallsPackage.java   
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<NativeModule>();
  modules.add(new RNForwardCallsModule(reactContext));
  return modules;
}
项目:react-native-device-brightness    文件:RNDeviceBrightness.java   
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new RNDeviceBrightnessModule(reactContext));

  return modules;
}