|
15 | 15 | import android.content.Context;
|
16 | 16 | import android.graphics.Canvas;
|
17 | 17 | import android.graphics.Rect;
|
18 |
| -import android.os.Build; |
19 | 18 | import android.os.Bundle;
|
20 | 19 | import android.util.AttributeSet;
|
21 |
| -import android.util.DisplayMetrics; |
22 | 20 | import android.view.KeyEvent;
|
23 | 21 | import android.view.MotionEvent;
|
24 | 22 | import android.view.Surface;
|
@@ -683,8 +681,6 @@ private class CustomGlobalLayoutListener implements ViewTreeObserver.OnGlobalLay
|
683 | 681 |
|
684 | 682 | private int mKeyboardHeight = 0;
|
685 | 683 | private int mDeviceRotation = 0;
|
686 |
| - private DisplayMetrics mWindowMetrics = new DisplayMetrics(); |
687 |
| - private DisplayMetrics mScreenMetrics = new DisplayMetrics(); |
688 | 684 |
|
689 | 685 | /* package */ CustomGlobalLayoutListener() {
|
690 | 686 | DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(getContext().getApplicationContext());
|
@@ -749,32 +745,8 @@ private void checkForDeviceOrientationChanges() {
|
749 | 745 | }
|
750 | 746 |
|
751 | 747 | private void checkForDeviceDimensionsChanges() {
|
752 |
| - // Get current display metrics. |
753 |
| - DisplayMetricsHolder.initDisplayMetrics(getContext()); |
754 |
| - // Check changes to both window and screen display metrics since they may not update at the |
755 |
| - // same time. |
756 |
| - if (!areMetricsEqual(mWindowMetrics, DisplayMetricsHolder.getWindowDisplayMetrics()) |
757 |
| - || !areMetricsEqual(mScreenMetrics, DisplayMetricsHolder.getScreenDisplayMetrics())) { |
758 |
| - mWindowMetrics.setTo(DisplayMetricsHolder.getWindowDisplayMetrics()); |
759 |
| - mScreenMetrics.setTo(DisplayMetricsHolder.getScreenDisplayMetrics()); |
760 |
| - emitUpdateDimensionsEvent(); |
761 |
| - } |
762 |
| - } |
763 |
| - |
764 |
| - private boolean areMetricsEqual(DisplayMetrics displayMetrics, DisplayMetrics otherMetrics) { |
765 |
| - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { |
766 |
| - return displayMetrics.equals(otherMetrics); |
767 |
| - } else { |
768 |
| - // DisplayMetrics didn't have an equals method before API 17. |
769 |
| - // Check all public fields manually. |
770 |
| - return displayMetrics.widthPixels == otherMetrics.widthPixels |
771 |
| - && displayMetrics.heightPixels == otherMetrics.heightPixels |
772 |
| - && displayMetrics.density == otherMetrics.density |
773 |
| - && displayMetrics.densityDpi == otherMetrics.densityDpi |
774 |
| - && displayMetrics.scaledDensity == otherMetrics.scaledDensity |
775 |
| - && displayMetrics.xdpi == otherMetrics.xdpi |
776 |
| - && displayMetrics.ydpi == otherMetrics.ydpi; |
777 |
| - } |
| 748 | + // DeviceInfoModule caches the last dimensions emitted to JS, so we don't need to check here. |
| 749 | + emitUpdateDimensionsEvent(); |
778 | 750 | }
|
779 | 751 |
|
780 | 752 | private void emitOrientationChanged(final int newRotation) {
|
|
0 commit comments