Permalink
Browse files

Introduce mobile config flag to load classes for View Managers

Reviewed By: kathryngray

Differential Revision: D6148468

fbshipit-source-id: d0f919f63922dae4b0720f22fa70ab4a7f67b48a
  • Loading branch information...
Dmitry Zakharov authored and facebook-github-bot committed Oct 26, 2017
1 parent 55f75df commit f0fb720eaa6a09f102ef61cfa6083c1f254f1edc
@@ -9,24 +9,22 @@
package com.facebook.react;
import javax.inject.Provider;
import java.util.ArrayList;
import java.util.List;
import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.modules.core.HeadlessJsTaskSupportModule;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.core.ExceptionsManagerModule;
import com.facebook.react.modules.core.HeadlessJsTaskSupportModule;
import com.facebook.react.modules.core.Timing;
import com.facebook.react.modules.debug.SourceCodeModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Provider;
/**
* Package defining core framework modules for basic JS interop.
@@ -61,54 +59,68 @@
List<ModuleSpec> moduleSpecList = new ArrayList<>();
moduleSpecList.add(
new ModuleSpec(AndroidInfoModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new AndroidInfoModule();
}
}));
ModuleSpec.nativeModuleSpec(
AndroidInfoModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new AndroidInfoModule();
}
}));
moduleSpecList.add(
ModuleSpec.nativeModuleSpec(
DeviceEventManagerModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
}
}));
moduleSpecList.add(
new ModuleSpec(DeviceEventManagerModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
}
}));
ModuleSpec.nativeModuleSpec(
ExceptionsManagerModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager());
}
}));
moduleSpecList.add(
new ModuleSpec(ExceptionsManagerModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager());
}
}));
moduleSpecList
.add(new ModuleSpec(HeadlessJsTaskSupportModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new HeadlessJsTaskSupportModule(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
HeadlessJsTaskSupportModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new HeadlessJsTaskSupportModule(reactContext);
}
}));
moduleSpecList.add(
new ModuleSpec(SourceCodeModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new SourceCodeModule(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
SourceCodeModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new SourceCodeModule(reactContext);
}
}));
moduleSpecList.add(
new ModuleSpec(Timing.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new Timing(reactContext, mReactInstanceManager.getDevSupportManager());
}
}));
ModuleSpec.nativeModuleSpec(
Timing.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new Timing(reactContext, mReactInstanceManager.getDevSupportManager());
}
}));
moduleSpecList.add(
new ModuleSpec(DeviceInfoModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceInfoModule(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
DeviceInfoModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceInfoModule(reactContext);
}
}));
return moduleSpecList;
}
@@ -98,16 +98,16 @@ public CompositeReactPackage(ReactPackage arg1, ReactPackage arg2, ReactPackage.
return new ArrayList<>(viewManagerMap.values());
}
/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public List<String> getViewManagerNames(ReactApplicationContext reactContext) {
public List<String> getViewManagerNames(
ReactApplicationContext reactContext, boolean loadClasses) {
Set<String> uniqueNames = new HashSet<>();
for (ReactPackage reactPackage : mChildReactPackages) {
if (reactPackage instanceof ViewManagerOnDemandReactPackage) {
List<String> names =
((ViewManagerOnDemandReactPackage) reactPackage).getViewManagerNames(reactContext);
((ViewManagerOnDemandReactPackage) reactPackage)
.getViewManagerNames(reactContext, loadClasses);
if (names != null) {
uniqueNames.addAll(names);
}
@@ -116,18 +116,17 @@ public CompositeReactPackage(ReactPackage arg1, ReactPackage arg2, ReactPackage.
return new ArrayList<>(uniqueNames);
}
/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public @Nullable ViewManager createViewManager(
ReactApplicationContext reactContext, String viewManagerName) {
ReactApplicationContext reactContext, String viewManagerName, boolean loadClasses) {
ListIterator<ReactPackage> iterator = mChildReactPackages.listIterator(mChildReactPackages.size());
while (iterator.hasPrevious()) {
ReactPackage reactPackage = iterator.previous();
if (reactPackage instanceof ViewManagerOnDemandReactPackage) {
ViewManager viewManager =
((ViewManagerOnDemandReactPackage) reactPackage).createViewManager(reactContext, viewManagerName);
((ViewManagerOnDemandReactPackage) reactPackage)
.createViewManager(reactContext, viewManagerName, loadClasses);
if (viewManager != null) {
return viewManager;
}
@@ -93,86 +93,107 @@
List<ModuleSpec> moduleSpecList = new ArrayList<>();
moduleSpecList.add(
new ModuleSpec(AndroidInfoModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new AndroidInfoModule();
}
}));
ModuleSpec.nativeModuleSpec(
AndroidInfoModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new AndroidInfoModule();
}
}));
moduleSpecList.add(
new ModuleSpec(AnimationsDebugModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new AnimationsDebugModule(
reactContext,
mReactInstanceManager.getDevSupportManager().getDevSettings());
}
}));
ModuleSpec.nativeModuleSpec(
AnimationsDebugModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new AnimationsDebugModule(
reactContext, mReactInstanceManager.getDevSupportManager().getDevSettings());
}
}));
moduleSpecList.add(
ModuleSpec.nativeModuleSpec(
DeviceEventManagerModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
}
}));
moduleSpecList.add(
new ModuleSpec(DeviceEventManagerModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
}
}));
ModuleSpec.nativeModuleSpec(
ExceptionsManagerModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager());
}
}));
moduleSpecList.add(
new ModuleSpec(ExceptionsManagerModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager());
}
}));
moduleSpecList
.add(new ModuleSpec(HeadlessJsTaskSupportModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new HeadlessJsTaskSupportModule(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
HeadlessJsTaskSupportModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new HeadlessJsTaskSupportModule(reactContext);
}
}));
moduleSpecList.add(
new ModuleSpec(SourceCodeModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new SourceCodeModule(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
SourceCodeModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new SourceCodeModule(reactContext);
}
}));
moduleSpecList.add(
new ModuleSpec(Timing.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new Timing(reactContext, mReactInstanceManager.getDevSupportManager());
}
}));
ModuleSpec.nativeModuleSpec(
Timing.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new Timing(reactContext, mReactInstanceManager.getDevSupportManager());
}
}));
moduleSpecList.add(
new ModuleSpec(UIManagerModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return createUIManager(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
UIManagerModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return createUIManager(reactContext);
}
}));
moduleSpecList.add(
new ModuleSpec(DeviceInfoModule.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceInfoModule(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
DeviceInfoModule.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new DeviceInfoModule(reactContext);
}
}));
if (ReactBuildConfig.DEBUG) {
moduleSpecList.add(
new ModuleSpec(JSCHeapCapture.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new JSCHeapCapture(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
JSCHeapCapture.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new JSCHeapCapture(reactContext);
}
}));
moduleSpecList.add(
new ModuleSpec(JSCSamplingProfiler.class, new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new JSCSamplingProfiler(reactContext);
}
}));
ModuleSpec.nativeModuleSpec(
JSCSamplingProfiler.class,
new Provider<NativeModule>() {
@Override
public NativeModule get() {
return new JSCSamplingProfiler(reactContext);
}
}));
}
return moduleSpecList;
Oops, something went wrong.

0 comments on commit f0fb720

Please sign in to comment.