mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
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:

committed by
Alexander Vakrilov

parent
ec24c5a96f
commit
2ee1d7dbd5
@ -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();
|
||||
|
Reference in New Issue
Block a user