mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 22:41:18 +08:00
don't block attaching ReactRootView on measuring
Reviewed By: achen1 Differential Revision: D5117394 fbshipit-source-id: 00f65a59247a75d4b42240fe25935aa9bd8948b1
This commit is contained in:
committed by
Facebook Github Bot
parent
23a34d4c65
commit
8125ce520d
@@ -78,8 +78,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
|
||||
private @Nullable CustomGlobalLayoutListener mCustomGlobalLayoutListener;
|
||||
private @Nullable ReactRootViewEventListener mRootViewEventListener;
|
||||
private int mRootViewTag;
|
||||
private boolean mWasMeasured = false;
|
||||
private boolean mIsAttachedToInstance = false;
|
||||
private boolean mIsAttachedToInstance;
|
||||
private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this);
|
||||
|
||||
public ReactRootView(Context context) {
|
||||
@@ -102,7 +101,6 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
|
||||
MeasureSpec.getSize(widthMeasureSpec),
|
||||
MeasureSpec.getSize(heightMeasureSpec));
|
||||
|
||||
mWasMeasured = true;
|
||||
// Check if we were waiting for onMeasure to attach the root view.
|
||||
if (mReactInstanceManager != null && !mIsAttachedToInstance) {
|
||||
attachToReactInstanceManager();
|
||||
@@ -222,12 +220,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
|
||||
mReactInstanceManager.createReactContextInBackground();
|
||||
}
|
||||
|
||||
// We need to wait for the initial onMeasure, if this view has not yet been measured, we set
|
||||
// which will make this view startReactApplication itself to instance manager once onMeasure
|
||||
// is called.
|
||||
if (mWasMeasured) {
|
||||
attachToReactInstanceManager();
|
||||
}
|
||||
attachToReactInstanceManager();
|
||||
} finally {
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
@@ -303,13 +296,12 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
|
||||
}
|
||||
|
||||
/**
|
||||
* Is used by unit test to setup mWasMeasured and mIsAttachedToWindow flags, that will let this
|
||||
* Is used by unit test to setup mIsAttachedToWindow flags, that will let this
|
||||
* view to be properly attached to catalyst instance by startReactApplication call
|
||||
*/
|
||||
@VisibleForTesting
|
||||
/* package */ void simulateAttachForTesting() {
|
||||
mIsAttachedToInstance = true;
|
||||
mWasMeasured = true;
|
||||
}
|
||||
|
||||
private CustomGlobalLayoutListener getCustomGlobalLayoutListener() {
|
||||
@@ -327,7 +319,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
|
||||
}
|
||||
|
||||
mIsAttachedToInstance = true;
|
||||
Assertions.assertNotNull(mReactInstanceManager).attachMeasuredRootView(this);
|
||||
Assertions.assertNotNull(mReactInstanceManager).attachRootView(this);
|
||||
getViewTreeObserver().addOnGlobalLayoutListener(getCustomGlobalLayoutListener());
|
||||
} finally {
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
@@ -362,6 +354,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
|
||||
private int mDeviceRotation = 0;
|
||||
|
||||
/* package */ CustomGlobalLayoutListener() {
|
||||
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(getContext().getApplicationContext());
|
||||
mVisibleViewArea = new Rect();
|
||||
mMinKeyboardHeightDetected = (int) PixelUtil.toPixelFromDIP(60);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user