mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-13 03:49:52 +08:00
Use a surface switch
Summary: Flesh out how surface will be used with a flag in ReactRootView Reviewed By: mdvacca Differential Revision: D14112897 fbshipit-source-id: adf6078048dbf83452d3523f0530a4d6dca7b3e8
This commit is contained in:
committed by
Facebook Github Bot
parent
c5b8b292e2
commit
bc06d1cc9c
@@ -1045,7 +1045,7 @@ public class ReactInstanceManager {
|
||||
|
||||
@Nullable Bundle initialProperties = rootView.getAppProperties();
|
||||
final int rootTag = uiManagerModule.addRootView(
|
||||
rootView,
|
||||
rootView.getView(),
|
||||
initialProperties == null ?
|
||||
new WritableNativeMap() : Arguments.fromBundle(initialProperties),
|
||||
rootView.getInitialUITemplate());
|
||||
|
||||
@@ -94,19 +94,29 @@ public class ReactRootView extends FrameLayout implements RootView {
|
||||
private int mLastWidth = 0;
|
||||
private int mLastHeight = 0;
|
||||
private @UIManagerType int mUIManagerType = DEFAULT;
|
||||
private final boolean mUseSurface;
|
||||
|
||||
public ReactRootView(Context context) {
|
||||
super(context);
|
||||
mUseSurface = false;
|
||||
init();
|
||||
}
|
||||
|
||||
public ReactRootView(Context context, boolean useSurface) {
|
||||
super(context);
|
||||
mUseSurface = useSurface;
|
||||
init();
|
||||
}
|
||||
|
||||
public ReactRootView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mUseSurface = false;
|
||||
init();
|
||||
}
|
||||
|
||||
public ReactRootView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mUseSurface = false;
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -114,8 +124,18 @@ public class ReactRootView extends FrameLayout implements RootView {
|
||||
setClipChildren(false);
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
// TODO add mUseSurface to return surface here
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (mUseSurface) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
return;
|
||||
}
|
||||
|
||||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.onMeasure");
|
||||
try {
|
||||
boolean measureSpecsUpdated = widthMeasureSpec != mWidthMeasureSpec ||
|
||||
@@ -287,6 +307,9 @@ public class ReactRootView extends FrameLayout implements RootView {
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
if (mUseSurface) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
}
|
||||
// No-op since UIManagerModule handles actually laying out children.
|
||||
}
|
||||
|
||||
@@ -365,6 +388,10 @@ public class ReactRootView extends FrameLayout implements RootView {
|
||||
mAppProperties = initialProperties;
|
||||
mInitialUITemplate = initialUITemplate;
|
||||
|
||||
if (mUseSurface) {
|
||||
// TODO initialize surface here
|
||||
}
|
||||
|
||||
if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
|
||||
mReactInstanceManager.createReactContextInBackground();
|
||||
}
|
||||
@@ -457,25 +484,31 @@ public class ReactRootView extends FrameLayout implements RootView {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mWasMeasured) {
|
||||
updateRootLayoutSpecs(mWidthMeasureSpec, mHeightMeasureSpec);
|
||||
}
|
||||
CatalystInstance catalystInstance = reactContext.getCatalystInstance();
|
||||
|
||||
WritableNativeMap appParams = new WritableNativeMap();
|
||||
appParams.putDouble("rootTag", getRootViewTag());
|
||||
@Nullable Bundle appProperties = getAppProperties();
|
||||
if (appProperties != null) {
|
||||
appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
|
||||
}
|
||||
if (getUIManagerType() == FABRIC) {
|
||||
appParams.putBoolean("fabric", true);
|
||||
}
|
||||
|
||||
mShouldLogContentAppeared = true;
|
||||
|
||||
String jsAppModuleName = getJSModuleName();
|
||||
catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
|
||||
|
||||
if (mUseSurface) {
|
||||
// TODO call surface's runApplication
|
||||
} else {
|
||||
|
||||
if (mWasMeasured) {
|
||||
updateRootLayoutSpecs(mWidthMeasureSpec, mHeightMeasureSpec);
|
||||
}
|
||||
|
||||
WritableNativeMap appParams = new WritableNativeMap();
|
||||
appParams.putDouble("rootTag", getRootViewTag());
|
||||
@Nullable Bundle appProperties = getAppProperties();
|
||||
if (appProperties != null) {
|
||||
appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
|
||||
}
|
||||
if (getUIManagerType() == FABRIC) {
|
||||
appParams.putBoolean("fabric", true);
|
||||
}
|
||||
|
||||
mShouldLogContentAppeared = true;
|
||||
|
||||
catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
|
||||
}
|
||||
} finally {
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user