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
This commit is contained in:
Peter Staev
2018-08-10 10:28:43 +03:00
committed by Alexander Vakrilov
parent ec24c5a96f
commit 2ee1d7dbd5

View File

@ -102,7 +102,7 @@ class Device implements DeviceDefinition {
class MainScreen implements ScreenMetricsDefinition { class MainScreen implements ScreenMetricsDefinition {
private _metrics: android.util.DisplayMetrics; private _metrics: android.util.DisplayMetrics;
private cssChanged(args: appModule.CssChangedEventData): void { private reinitMetrics(): void {
if (!this._metrics) { if (!this._metrics) {
this._metrics = new android.util.DisplayMetrics(); this._metrics = new android.util.DisplayMetrics();
} }
@ -117,7 +117,8 @@ class MainScreen implements ScreenMetricsDefinition {
private get metrics(): android.util.DisplayMetrics { private get metrics(): android.util.DisplayMetrics {
if (!this._metrics) { if (!this._metrics) {
// NOTE: This will be memory leak but we MainScreen is singleton // 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._metrics = new android.util.DisplayMetrics();
this.initMetrics(); this.initMetrics();