mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 12:05:06 +00:00
On Android, seperate logic to initialize JS from starting the app
Reviewed By: achen1 Differential Revision: D6606265 fbshipit-source-id: d432661b5f8aa2b7600b1140e1617aab852f343e
This commit is contained in:
parent
19a9c5e41d
commit
4996b9aeb4
@ -1044,7 +1044,7 @@ public class ReactInstanceManager {
|
|||||||
UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
|
UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
|
||||||
final int rootTag = uiManagerModule.addRootView(rootView);
|
final int rootTag = uiManagerModule.addRootView(rootView);
|
||||||
rootView.setRootViewTag(rootTag);
|
rootView.setRootViewTag(rootTag);
|
||||||
rootView.runApplication();
|
rootView.invokeJSEntryPoint();
|
||||||
Systrace.beginAsyncSection(
|
Systrace.beginAsyncSection(
|
||||||
TRACE_TAG_REACT_JAVA_BRIDGE,
|
TRACE_TAG_REACT_JAVA_BRIDGE,
|
||||||
"pre_rootView.onAttachedToReactInstance",
|
"pre_rootView.onAttachedToReactInstance",
|
||||||
|
@ -87,6 +87,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
|||||||
private boolean mWasMeasured = false;
|
private boolean mWasMeasured = false;
|
||||||
private int mWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
private int mWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||||
private int mHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
private int mHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||||
|
private @Nullable Runnable mJSEntryPoint;
|
||||||
|
|
||||||
public ReactRootView(Context context) {
|
public ReactRootView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -379,7 +380,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
|||||||
UiThreadUtil.assertOnUiThread();
|
UiThreadUtil.assertOnUiThread();
|
||||||
mAppProperties = appProperties;
|
mAppProperties = appProperties;
|
||||||
if (getRootViewTag() != 0) {
|
if (getRootViewTag() != 0) {
|
||||||
runApplication();
|
invokeJSEntryPoint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +388,34 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
|||||||
* Calls into JS to start the React application. Can be called multiple times with the
|
* Calls into JS to start the React application. Can be called multiple times with the
|
||||||
* same rootTag, which will re-render the application from the root.
|
* same rootTag, which will re-render the application from the root.
|
||||||
*/
|
*/
|
||||||
/* package */ void runApplication() {
|
/*package */ void invokeJSEntryPoint() {
|
||||||
|
if (mJSEntryPoint == null) {
|
||||||
|
defaultJSEntryPoint();
|
||||||
|
} else {
|
||||||
|
mJSEntryPoint.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a custom entry point for invoking JS. By default, this is AppRegistry.runApplication
|
||||||
|
* @param jsEntryPoint
|
||||||
|
*/
|
||||||
|
public void setJSEntryPoint(Runnable jsEntryPoint) {
|
||||||
|
mJSEntryPoint = jsEntryPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invokeDefaultJSEntryPoint(@Nullable Bundle appProperties) {
|
||||||
|
UiThreadUtil.assertOnUiThread();
|
||||||
|
if (appProperties != null) {
|
||||||
|
mAppProperties = appProperties;
|
||||||
|
}
|
||||||
|
defaultJSEntryPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the default entry point into JS which is AppRegistry.runApplication()
|
||||||
|
*/
|
||||||
|
private void defaultJSEntryPoint() {
|
||||||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication");
|
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication");
|
||||||
try {
|
try {
|
||||||
if (mReactInstanceManager == null || !mIsAttachedToInstance) {
|
if (mReactInstanceManager == null || !mIsAttachedToInstance) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user