mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor duplicated code in ReactRootView
Summary: Quick refactor of ReactRootView where I extract 'Fabric' check into a method changelog: [internal] internal Reviewed By: fkgozali Differential Revision: D33269025 fbshipit-source-id: 2647d5870f3b5fcc5a940a5924a39ca43b5bebac
This commit is contained in:
committed by
Facebook GitHub Bot
parent
679e131972
commit
05ce2cf259
@@ -335,11 +335,15 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
// No-op in non-Fabric since UIManagerModule handles actually laying out children.
|
||||
|
||||
// In Fabric, update LayoutSpecs just so we update the offsetX and offsetY.
|
||||
if (mWasMeasured && getUIManagerType() == FABRIC) {
|
||||
if (mWasMeasured && isFabric()) {
|
||||
updateRootLayoutSpecs(false, mWidthMeasureSpec, mHeightMeasureSpec);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFabric() {
|
||||
return getUIManagerType() == FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
@@ -509,7 +513,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
}
|
||||
// In Fabric we cannot call `updateRootLayoutSpecs` until a SurfaceId has been set.
|
||||
// Sometimes,
|
||||
if (getUIManagerType() == FABRIC && !isRootViewTagSet()) {
|
||||
boolean isFabricEnabled = isFabric();
|
||||
if (isFabricEnabled && !isRootViewTagSet()) {
|
||||
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_UPDATE_LAYOUT_SPECS_END);
|
||||
FLog.e(TAG, "Unable to update root layout specs for ReactRootView: no rootViewTag set yet");
|
||||
return;
|
||||
@@ -526,7 +531,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
// In Fabric only, get position of view within screen
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
if (getUIManagerType() == FABRIC) {
|
||||
if (isFabricEnabled) {
|
||||
Point viewportOffset = RootViewUtil.getViewportOffset(this);
|
||||
offsetX = viewportOffset.x;
|
||||
offsetY = viewportOffset.y;
|
||||
@@ -561,7 +566,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
// all the views in the hierarchy.
|
||||
if (mReactInstanceManager != null) {
|
||||
final ReactContext reactApplicationContext = mReactInstanceManager.getCurrentReactContext();
|
||||
if (reactApplicationContext != null && getUIManagerType() == FABRIC) {
|
||||
if (reactApplicationContext != null && isFabric()) {
|
||||
@Nullable
|
||||
UIManager uiManager =
|
||||
UIManagerHelper.getUIManager(reactApplicationContext, getUIManagerType());
|
||||
|
||||
Reference in New Issue
Block a user