Begin inverting dependency between new+old bridge

Reviewed By: mhorowitz

Differential Revision: D3306510

fbshipit-source-id: 312a498a4461e980f1f749fe7858a13be14dfa2f
This commit is contained in:
Chris Hopman
2016-06-07 13:25:20 -07:00
committed by Facebook Github Bot 0
parent 26a5b033f8
commit 5b871ad9d7
4 changed files with 47 additions and 85 deletions

View File

@@ -195,6 +195,7 @@ public abstract class ReactInstanceManager {
protected @Nullable Activity mCurrentActivity;
protected @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler;
protected @Nullable RedBoxHandler mRedBoxHandler;
protected boolean mUseNewBridge;
protected Builder() {
}
@@ -309,6 +310,11 @@ public abstract class ReactInstanceManager {
return this;
}
public Builder setUseNewBridge() {
mUseNewBridge = true;
return this;
}
/**
* Instantiates a new {@link ReactInstanceManagerImpl}.
* Before calling {@code build}, the following must be called:
@@ -333,22 +339,41 @@ public abstract class ReactInstanceManager {
mUIImplementationProvider = new UIImplementationProvider();
}
return new ReactInstanceManagerImpl(
Assertions.assertNotNull(
mApplication,
"Application property has not been set with this builder"),
mCurrentActivity,
mDefaultHardwareBackBtnHandler,
mJSBundleFile,
mJSMainModuleName,
mPackages,
mUseDeveloperSupport,
mBridgeIdleDebugListener,
Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
mUIImplementationProvider,
mNativeModuleCallExceptionHandler,
mJSCConfig,
mRedBoxHandler);
if (mUseNewBridge) {
return new XReactInstanceManagerImpl(
Assertions.assertNotNull(
mApplication,
"Application property has not been set with this builder"),
mCurrentActivity,
mDefaultHardwareBackBtnHandler,
mJSBundleFile,
mJSMainModuleName,
mPackages,
mUseDeveloperSupport,
mBridgeIdleDebugListener,
Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
mUIImplementationProvider,
mNativeModuleCallExceptionHandler,
mJSCConfig,
mRedBoxHandler);
} else {
return new ReactInstanceManagerImpl(
Assertions.assertNotNull(
mApplication,
"Application property has not been set with this builder"),
mCurrentActivity,
mDefaultHardwareBackBtnHandler,
mJSBundleFile,
mJSMainModuleName,
mPackages,
mUseDeveloperSupport,
mBridgeIdleDebugListener,
Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
mUIImplementationProvider,
mNativeModuleCallExceptionHandler,
mJSCConfig,
mRedBoxHandler);
}
}
}
}