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; }
@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) ); }
/** * {@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()); }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new RNSweetAlertModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new MusicPlayerModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new WebRTCModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new RNSpeechToText(reactApplicationContext)); return modules; }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new DownloadFileManager(reactContext)); return modules; }
public ModuleHolder(NativeModule nativeModule) { mName = nativeModule.getName(); mCanOverrideExistingModule = nativeModule.canOverrideExistingModule(); mSupportsWebWorkers = nativeModule.supportsWebWorkers(); mHasConstants = true; mModule = nativeModule; }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new NfcManager(reactApplicationContext)); return modules; }
/** * @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; }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new SystemSetting(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new BackgroundTaskModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new SomeExampleModule(reactContext)); return modules; }
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; }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new AddPermissions(reactContext)); modules.add(new UsersDB(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new DialogModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new RNExitAppModule(reactContext)); return modules; }
@Override public ReactInstanceEasyBuilder addNativeModule(NativeModule nativeModule) { if (mNativeModuleRegistryBuilder == null) { mNativeModuleRegistryBuilder = new NativeModuleRegistryBuilder( (ReactApplicationContext) mContext, null, false); } mNativeModuleRegistryBuilder.addNativeModule(nativeModule); return this; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new KeyValueStorageModule(reactContext)); return modules; }
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); } } }
public JavaModuleWrapper(JSInstance jsInstance, Class<? extends NativeModule> moduleClass, ModuleHolder moduleHolder) { mJSInstance = jsInstance; mModuleHolder = moduleHolder; mModuleClass = moduleClass; mMethods = new ArrayList<>(); mDescs = new ArrayList(); }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new OnfidoSDK(reactContext)); return modules; }
@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); }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new GrowingIOModule(reactContext)); return modules; }
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; }
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); }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { return Arrays.<NativeModule>asList( new RNCrashReporter(reactContext, currentActivity) ); }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new CallLogModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new SunmiInnerPrinterModule(reactContext)); return modules; }
@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))); }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new ScreenShotDetectModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new RNIconBadgeModule(reactContext)); return modules; }
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); }
public NativeModuleRegistry( ReactApplicationContext reactApplicationContext, Map<Class<? extends NativeModule>, ModuleHolder> modules, ArrayList<ModuleHolder> batchCompleteListenerModules) { mReactApplicationContext = reactApplicationContext; mModules = modules; mBatchCompleteListenerModules = batchCompleteListenerModules; }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new AsyncStorageDevMenuItemModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new RNNavitiaSDK(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<NativeModule>(); modules.add(new RNForwardCallsModule(reactContext)); return modules; }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { List<NativeModule> modules = new ArrayList<>(); modules.add(new RNDeviceBrightnessModule(reactContext)); return modules; }