From 6d6295ade04d3b1d8b8ebf9b06a30e37c1b4a4a7 Mon Sep 17 00:00:00 2001 From: ajpaulingalls Date: Thu, 5 Nov 2020 10:19:15 -0800 Subject: [PATCH] Currently the dimensions are created once, and then cached. This change will reload the dimensions when the device orientation changes to insure that dimension update events follow orientation changed events. --- .../src/main/java/com/facebook/react/ReactRootView.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 9098fa1a2fc4db..8973dfad100b1d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -711,7 +711,9 @@ public void onGlobalLayout() { return; } checkForKeyboardEvents(); - checkForDeviceOrientationChanges(); + if (checkForDeviceOrientationChanges()) { + DisplayMetricsHolder.initDisplayMetrics(getContext().getApplicationContext()); + } checkForDeviceDimensionsChanges(); } @@ -747,16 +749,17 @@ private void checkForKeyboardEvents() { } } - private void checkForDeviceOrientationChanges() { + private boolean checkForDeviceOrientationChanges() { final int rotation = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay() .getRotation(); if (mDeviceRotation == rotation) { - return; + return false; } mDeviceRotation = rotation; emitOrientationChanged(rotation); + return true; } private void checkForDeviceDimensionsChanges() {