Add UIImplementationProvider and allow overriding it in AbstractReactActivity

Summary: public UIImplementationProvider allows plugging in an alternative UIImplementation. A follow up diff adds a toggle under FB Dev Settings and uses this class to control an implementation. This allows us experimenting with other ways of generating UI hierarchy from JavaScript components.

Reviewed By: astreet

Differential Revision: D2554774

fb-gh-sync-id: 6574a893020e3519bd2ab00b9620a6dbdfaed595
This commit is contained in:
Denis Koroskin
2015-11-29 22:24:36 -08:00
committed by facebook-github-bot-7
parent e8e7a2db57
commit 3dca8cf9fd
5 changed files with 57 additions and 16 deletions

View File

@@ -52,6 +52,7 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.uimanager.AppRegistry;
import com.facebook.react.uimanager.ReactNative;
import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.soloader.SoLoader;
@@ -95,6 +96,7 @@ import com.facebook.systrace.Systrace;
private String mSourceUrl;
private @Nullable Activity mCurrentActivity;
private volatile boolean mHasStartedCreatingInitialContext = false;
private final UIImplementationProvider mUIImplementationProvider;
private final ReactInstanceDevCommandsHandler mDevInterface =
new ReactInstanceDevCommandsHandler() {
@@ -189,7 +191,8 @@ import com.facebook.systrace.Systrace;
List<ReactPackage> packages,
boolean useDeveloperSupport,
@Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
LifecycleState initialLifecycleState) {
LifecycleState initialLifecycleState,
UIImplementationProvider uiImplementationProvider) {
initializeSoLoaderIfNecessary(applicationContext);
mApplicationContext = applicationContext;
@@ -208,6 +211,7 @@ import com.facebook.systrace.Systrace;
useDeveloperSupport);
mBridgeIdleDebugListener = bridgeIdleDebugListener;
mLifecycleState = initialLifecycleState;
mUIImplementationProvider = uiImplementationProvider;
}
@Override
@@ -597,7 +601,7 @@ import com.facebook.systrace.Systrace;
"createAndProcessCoreModulesPackage");
try {
CoreModulesPackage coreModulesPackage =
new CoreModulesPackage(this, mBackBtnHandler);
new CoreModulesPackage(this, mBackBtnHandler, mUIImplementationProvider);
processPackage(coreModulesPackage, reactContext, nativeRegistryBuilder, jsModulesBuilder);
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);