mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 08:05:34 +00:00
Update size of Root ShadowNode when RootView changes its size
Summary: This diff updates the size of RootShadowNode and re-render RN views when the Size of the Android React View changes Reviewed By: achen1 Differential Revision: D9173758 fbshipit-source-id: 7cc6bbfb646025c3ec1773ab041eb9207623af71
This commit is contained in:
parent
575f7d478d
commit
8b5e3fc16b
@ -408,16 +408,10 @@ public class ReactRootView extends SizeMonitoringFrameLayout
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ReactContext reactApplicationContext = mReactInstanceManager.getCurrentReactContext();
|
final ReactContext reactApplicationContext = mReactInstanceManager.getCurrentReactContext();
|
||||||
|
|
||||||
if (reactApplicationContext != null) {
|
if (reactApplicationContext != null) {
|
||||||
reactApplicationContext.runOnNativeModulesQueueThread(
|
UIManagerHelper.getUIManager(reactApplicationContext, getUIManagerType())
|
||||||
new GuardedRunnable(reactApplicationContext) {
|
.updateRootLayoutSpecs(getRootViewTag(), widthMeasureSpec, heightMeasureSpec);
|
||||||
@Override
|
|
||||||
public void runGuarded() {
|
|
||||||
UIManagerHelper
|
|
||||||
.getUIManager(reactApplicationContext, getUIManagerType())
|
|
||||||
.updateRootLayoutSpecs(getRootViewTag(), widthMeasureSpec, heightMeasureSpec);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,16 +512,21 @@ public class FabricUIManager implements UIManager, JSHandler, FabricBinder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
public synchronized void updateRootLayoutSpecs(int rootViewTag, int widthMeasureSpec, int heightMeasureSpec) {
|
public synchronized void updateRootLayoutSpecs(final int rootViewTag, final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||||
ReactShadowNode rootNode = getRootNode(rootViewTag);
|
mReactApplicationContext.runOnNativeModulesQueueThread(new Runnable() {
|
||||||
if (rootNode == null) {
|
@Override
|
||||||
FLog.w(ReactConstants.TAG, "Tried to update non-existent root tag: " + rootViewTag);
|
public void run() {
|
||||||
return;
|
ReactShadowNode rootNode = getRootNode(rootViewTag);
|
||||||
}
|
if (rootNode == null) {
|
||||||
|
FLog.w(ReactConstants.TAG, "Tried to update non-existent root tag: " + rootViewTag);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ReactShadowNode newRootNode = rootNode.mutableCopy(rootNode.getInstanceHandle());
|
ReactShadowNode newRootNode = rootNode.mutableCopy(rootNode.getInstanceHandle());
|
||||||
updateRootView(newRootNode, widthMeasureSpec, heightMeasureSpec);
|
updateRootView(newRootNode, widthMeasureSpec, heightMeasureSpec);
|
||||||
mRootShadowNodeRegistry.replaceNode(newRootNode);
|
mRootShadowNodeRegistry.replaceNode(newRootNode);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,4 +55,11 @@ public class PixelUtil {
|
|||||||
return value / DisplayMetricsHolder.getWindowDisplayMetrics().density;
|
return value / DisplayMetricsHolder.getWindowDisplayMetrics().density;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link float} that represents the density of the display metrics for device screen.
|
||||||
|
*/
|
||||||
|
public static float getDisplayMetricDensity() {
|
||||||
|
return DisplayMetricsHolder.getScreenDisplayMetrics().density;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -784,9 +784,15 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
|||||||
* Updates the styles of the {@link ReactShadowNode} based on the Measure specs received by
|
* Updates the styles of the {@link ReactShadowNode} based on the Measure specs received by
|
||||||
* parameters.
|
* parameters.
|
||||||
*/
|
*/
|
||||||
public void updateRootLayoutSpecs(int rootViewTag, int widthMeasureSpec, int heightMeasureSpec) {
|
public void updateRootLayoutSpecs(final int rootViewTag, final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||||
mUIImplementation.updateRootView(rootViewTag, widthMeasureSpec, heightMeasureSpec);
|
ReactApplicationContext reactApplicationContext = getReactApplicationContext();
|
||||||
mUIImplementation.dispatchViewUpdates(-1);
|
reactApplicationContext.runOnNativeModulesQueueThread(
|
||||||
|
new GuardedRunnable(reactApplicationContext) {
|
||||||
|
@Override
|
||||||
|
public void runGuarded() {
|
||||||
|
mUIImplementation.updateRootView(rootViewTag, widthMeasureSpec, heightMeasureSpec);
|
||||||
|
mUIImplementation.dispatchViewUpdates(-1);
|
||||||
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Listener that drops the CSSNode pool on low memory when the app is backgrounded. */
|
/** Listener that drops the CSSNode pool on low memory when the app is backgrounded. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user