From 2ee1d7dbd5c60e6d8697e5d6cd25e8321da296a2 Mon Sep 17 00:00:00 2001 From: Peter Staev Date: Fri, 10 Aug 2018 10:28:43 +0300 Subject: [PATCH] fix(android/platform): reinitialise screen metrics on orientation change (#6164) * fix(android/platform): reinitialise screen metrics on orientation change * fix(android/platform): reinitialise screen metrics on orientation change --- tns-core-modules/platform/platform.android.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tns-core-modules/platform/platform.android.ts b/tns-core-modules/platform/platform.android.ts index decf466e1..7325ea317 100644 --- a/tns-core-modules/platform/platform.android.ts +++ b/tns-core-modules/platform/platform.android.ts @@ -101,8 +101,8 @@ class Device implements DeviceDefinition { class MainScreen implements ScreenMetricsDefinition { private _metrics: android.util.DisplayMetrics; - - private cssChanged(args: appModule.CssChangedEventData): void { + + private reinitMetrics(): void { if (!this._metrics) { this._metrics = new android.util.DisplayMetrics(); } @@ -117,7 +117,8 @@ class MainScreen implements ScreenMetricsDefinition { private get metrics(): android.util.DisplayMetrics { if (!this._metrics) { // NOTE: This will be memory leak but we MainScreen is singleton - appModule.on("cssChanged", this.cssChanged, this); + appModule.on("cssChanged", this.reinitMetrics, this); + appModule.on(appModule.orientationChangedEvent, this.reinitMetrics, this); this._metrics = new android.util.DisplayMetrics(); this.initMetrics();