mirror of
https://github.com/status-im/react-native.git
synced 2025-03-01 01:20:31 +00:00
Begin inverting dependency between new+old bridge
Reviewed By: mhorowitz Differential Revision: D3306510 fbshipit-source-id: 312a498a4461e980f1f749fe7858a13be14dfa2f
This commit is contained in:
parent
26a5b033f8
commit
5b871ad9d7
@ -1,11 +1,7 @@
|
|||||||
include_defs('//ReactAndroid/DEFS')
|
include_defs('//ReactAndroid/DEFS')
|
||||||
|
|
||||||
XREACT_SRCS = [
|
|
||||||
'XReactInstanceManager.java',
|
|
||||||
'XReactInstanceManagerImpl.java',
|
|
||||||
]
|
|
||||||
|
|
||||||
DEPS = [
|
DEPS = [
|
||||||
|
react_native_target('java/com/facebook/react/cxxbridge:bridge'),
|
||||||
react_native_target('java/com/facebook/react/bridge:bridge'),
|
react_native_target('java/com/facebook/react/bridge:bridge'),
|
||||||
react_native_target('java/com/facebook/react/common:common'),
|
react_native_target('java/com/facebook/react/common:common'),
|
||||||
react_native_target('java/com/facebook/react/devsupport:devsupport'),
|
react_native_target('java/com/facebook/react/devsupport:devsupport'),
|
||||||
@ -23,25 +19,13 @@ DEPS = [
|
|||||||
|
|
||||||
android_library(
|
android_library(
|
||||||
name = 'react',
|
name = 'react',
|
||||||
srcs = glob(['*.java'], excludes=XREACT_SRCS),
|
srcs = glob(['*.java']),
|
||||||
deps = DEPS,
|
deps = DEPS,
|
||||||
visibility = [
|
visibility = [
|
||||||
'PUBLIC',
|
'PUBLIC',
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
android_library(
|
|
||||||
name = 'xreact',
|
|
||||||
srcs = XREACT_SRCS,
|
|
||||||
deps = DEPS + [
|
|
||||||
':react',
|
|
||||||
react_native_target('java/com/facebook/react/cxxbridge:bridge'),
|
|
||||||
],
|
|
||||||
visibility = [
|
|
||||||
'PUBLIC',
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
project_config(
|
project_config(
|
||||||
src_target = ':react',
|
src_target = ':react',
|
||||||
)
|
)
|
||||||
|
@ -195,6 +195,7 @@ public abstract class ReactInstanceManager {
|
|||||||
protected @Nullable Activity mCurrentActivity;
|
protected @Nullable Activity mCurrentActivity;
|
||||||
protected @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler;
|
protected @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler;
|
||||||
protected @Nullable RedBoxHandler mRedBoxHandler;
|
protected @Nullable RedBoxHandler mRedBoxHandler;
|
||||||
|
protected boolean mUseNewBridge;
|
||||||
|
|
||||||
protected Builder() {
|
protected Builder() {
|
||||||
}
|
}
|
||||||
@ -309,6 +310,11 @@ public abstract class ReactInstanceManager {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setUseNewBridge() {
|
||||||
|
mUseNewBridge = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new {@link ReactInstanceManagerImpl}.
|
* Instantiates a new {@link ReactInstanceManagerImpl}.
|
||||||
* Before calling {@code build}, the following must be called:
|
* Before calling {@code build}, the following must be called:
|
||||||
@ -333,6 +339,24 @@ public abstract class ReactInstanceManager {
|
|||||||
mUIImplementationProvider = new UIImplementationProvider();
|
mUIImplementationProvider = new UIImplementationProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
return new ReactInstanceManagerImpl(
|
||||||
Assertions.assertNotNull(
|
Assertions.assertNotNull(
|
||||||
mApplication,
|
mApplication,
|
||||||
@ -351,4 +375,5 @@ public abstract class ReactInstanceManager {
|
|||||||
mRedBoxHandler);
|
mRedBoxHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,56 +14,9 @@ import com.facebook.react.uimanager.UIImplementationProvider;
|
|||||||
|
|
||||||
public abstract class XReactInstanceManager {
|
public abstract class XReactInstanceManager {
|
||||||
/**
|
/**
|
||||||
* Creates a builder that is capable of creating an instance of {@link XReactInstanceManagerImpl}.
|
* Creates a builder that is defaulted to using the new bridge.
|
||||||
*/
|
*/
|
||||||
public static Builder builder() {
|
public static ReactInstanceManager.Builder builder() {
|
||||||
return new Builder();
|
return new ReactInstanceManager.Builder().setUseNewBridge();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builder class for {@link XReactInstanceManagerImpl}
|
|
||||||
*/
|
|
||||||
public static class Builder extends ReactInstanceManager.Builder {
|
|
||||||
/**
|
|
||||||
* Instantiates a new {@link ReactInstanceManagerImpl}.
|
|
||||||
* Before calling {@code build}, the following must be called:
|
|
||||||
* <ul>
|
|
||||||
* <li> {@link #setApplication}
|
|
||||||
* <li> {@link #setCurrentActivity} if the activity has already resumed
|
|
||||||
* <li> {@link #setDefaultHardwareBackBtnHandler} if the activity has already resumed
|
|
||||||
* <li> {@link #setJSBundleFile} or {@link #setJSMainModuleName}
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public ReactInstanceManager build() {
|
|
||||||
Assertions.assertCondition(
|
|
||||||
mUseDeveloperSupport || mJSBundleFile != null,
|
|
||||||
"JS Bundle File has to be provided when dev support is disabled");
|
|
||||||
|
|
||||||
Assertions.assertCondition(
|
|
||||||
mJSMainModuleName != null || mJSBundleFile != null,
|
|
||||||
"Either MainModuleName or JS Bundle File needs to be provided");
|
|
||||||
|
|
||||||
if (mUIImplementationProvider == null) {
|
|
||||||
// create default UIImplementationProvider if the provided one is null.
|
|
||||||
mUIImplementationProvider = new UIImplementationProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ android_library(
|
|||||||
],
|
],
|
||||||
proguard_config = 'bridge.pro',
|
proguard_config = 'bridge.pro',
|
||||||
deps = [
|
deps = [
|
||||||
'//libraries/fbcore/src/main/java/com/facebook/common/logging:logging',
|
|
||||||
react_native_dep('java/com/facebook/systrace:systrace'),
|
react_native_dep('java/com/facebook/systrace:systrace'),
|
||||||
|
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
|
||||||
react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'),
|
react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'),
|
||||||
# TODO mhorowitz:
|
# TODO mhorowitz:
|
||||||
# java/com/facebook/catalyst/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/bridge/
|
# java/com/facebook/catalyst/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/bridge/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user