mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* tslint:disable:class-name */
|
||||
import * as appModule from '../application';
|
||||
import { getNativeApplication, on, off, orientationChangedEvent } from '../application';
|
||||
|
||||
const MIN_TABLET_PIXELS = 600;
|
||||
|
||||
@@ -19,15 +19,15 @@ class MainScreen {
|
||||
}
|
||||
|
||||
private initMetrics(): void {
|
||||
const nativeApp = <android.app.Application>appModule.getNativeApplication();
|
||||
const nativeApp = <android.app.Application>getNativeApplication();
|
||||
nativeApp.getSystemService(android.content.Context.WINDOW_SERVICE).getDefaultDisplay().getRealMetrics(this._metrics);
|
||||
}
|
||||
|
||||
private get metrics(): android.util.DisplayMetrics {
|
||||
if (!this._metrics) {
|
||||
// NOTE: This will be memory leak but we MainScreen is singleton
|
||||
appModule.on('cssChanged', this.reinitMetrics, this);
|
||||
appModule.on(appModule.orientationChangedEvent, this.reinitMetrics, this);
|
||||
on('cssChanged', this.reinitMetrics, this);
|
||||
on(orientationChangedEvent, this.reinitMetrics, this);
|
||||
|
||||
this._metrics = new android.util.DisplayMetrics();
|
||||
this.initMetrics();
|
||||
|
||||
Reference in New Issue
Block a user