diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index fd8f76c30..347658583 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -130,16 +130,17 @@ public class UIImplementation { } /** - * Invoked when native view that corresponds to a root node has its size changed. + * Invoked when native view that corresponds to a root node, or acts as a root view (ie. Modals) + * has its size changed. */ - public void updateRootNodeSize( - int rootViewTag, + public void updateNodeSize( + int nodeViewTag, int newWidth, int newHeight, EventDispatcher eventDispatcher) { - ReactShadowNode rootCSSNode = mShadowNodeRegistry.getNode(rootViewTag); - rootCSSNode.setStyleWidth(newWidth); - rootCSSNode.setStyleHeight(newHeight); + ReactShadowNode cssNode = mShadowNodeRegistry.getNode(nodeViewTag); + cssNode.setStyleWidth(newWidth); + cssNode.setStyleHeight(newHeight); // If we're in the middle of a batch, the change will automatically be dispatched at the end of // the batch. As all batches are executed as a single runnable on the event queue this should diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 5ec09e13c..2cfe95de2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -192,7 +192,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements new Runnable() { @Override public void run() { - updateRootNodeSize(tag, width, height); + updateNodeSize(tag, width, height); } }); } @@ -206,10 +206,10 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements mUIImplementation.removeRootView(rootViewTag); } - private void updateRootNodeSize(int rootViewTag, int newWidth, int newHeight) { + public void updateNodeSize(int nodeViewTag, int newWidth, int newHeight) { getReactApplicationContext().assertOnNativeModulesQueueThread(); - mUIImplementation.updateRootNodeSize(rootViewTag, newWidth, newHeight, mEventDispatcher); + mUIImplementation.updateNodeSize(nodeViewTag, newWidth, newHeight, mEventDispatcher); } @ReactMethod diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java index ddf821d45..3d03bd8b3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java @@ -264,6 +264,21 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe super(context); } + @Override + protected void onSizeChanged(final int w, final int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + if (getChildCount() > 0) { + ((ReactContext) getContext()).runOnNativeModulesQueueThread( + new Runnable() { + @Override + public void run() { + ((ReactContext) getContext()).getNativeModule(UIManagerModule.class) + .updateNodeSize(getChildAt(0).getId(), w, h); + } + }); + } + } + @Override public boolean onInterceptTouchEvent(MotionEvent event) { mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher());