mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
@@ -14,6 +14,7 @@ import type { AndroidApplication as AndroidApplicationType, iOSApplication as iO
|
||||
import type { ApplicationEventData, CssChangedEventData, DiscardedErrorEventData, FontScaleChangedEventData, InitRootViewEventData, LaunchEventData, LoadAppCSSEventData, NativeScriptError, OrientationChangedEventData, SystemAppearanceChangedEventData, UnhandledErrorEventData } from './application-interfaces';
|
||||
import { readyInitAccessibilityCssHelper, readyInitFontScale } from '../accessibility/accessibility-common';
|
||||
import { getAppMainEntry, isAppInBackground, setAppInBackground, setAppMainEntry } from './helpers-common';
|
||||
import { getNativeScriptGlobals } from '../globals/global-utils';
|
||||
|
||||
// prettier-ignore
|
||||
const ORIENTATION_CSS_CLASSES = [
|
||||
@@ -28,7 +29,7 @@ const SYSTEM_APPEARANCE_CSS_CLASSES = [
|
||||
`${CSSUtils.CLASS_PREFIX}${CoreTypes.SystemAppearance.dark}`,
|
||||
];
|
||||
|
||||
const globalEvents = global.NativeScriptGlobals.events;
|
||||
const globalEvents = getNativeScriptGlobals().events;
|
||||
|
||||
// helper interface to correctly type Application event handlers
|
||||
interface ApplicationEvents {
|
||||
@@ -161,7 +162,7 @@ export class ApplicationCommon {
|
||||
* @internal - should not be constructed by the user.
|
||||
*/
|
||||
constructor() {
|
||||
global.NativeScriptGlobals.appInstanceReady = true;
|
||||
getNativeScriptGlobals().appInstanceReady = true;
|
||||
|
||||
global.__onUncaughtError = (error: NativeScriptError) => {
|
||||
this.notify({
|
||||
@@ -507,7 +508,7 @@ export class ApplicationCommon {
|
||||
}
|
||||
|
||||
hasLaunched(): boolean {
|
||||
return global.NativeScriptGlobals && global.NativeScriptGlobals.launched;
|
||||
return getNativeScriptGlobals().launched;
|
||||
}
|
||||
|
||||
private _systemAppearance: 'dark' | 'light' | null;
|
||||
|
||||
@@ -42,6 +42,7 @@ import {
|
||||
} from '../accessibility/accessibility-common';
|
||||
import { androidGetForegroundActivity, androidGetStartActivity, androidPendingReceiverRegistrations, androidRegisterBroadcastReceiver, androidRegisteredReceivers, androidSetForegroundActivity, androidSetStartActivity, androidUnregisterBroadcastReceiver, applyContentDescription } from './helpers';
|
||||
import { getImageFetcher, getNativeApp, getRootView, initImageCache, setA11yUpdatePropertiesCallback, setApplicationPropertiesCallback, setAppMainEntry, setNativeApp, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common';
|
||||
import { getNativeScriptGlobals } from '../globals/global-utils';
|
||||
|
||||
declare class NativeScriptLifecycleCallbacks extends android.app.Application.ActivityLifecycleCallbacks {}
|
||||
|
||||
@@ -1364,9 +1365,9 @@ function onLiveSync(args): void {
|
||||
}
|
||||
}
|
||||
|
||||
global.NativeScriptGlobals.events.on('livesync', onLiveSync);
|
||||
getNativeScriptGlobals().events.on('livesync', onLiveSync);
|
||||
|
||||
global.NativeScriptGlobals.addEventWiring(() => {
|
||||
getNativeScriptGlobals().addEventWiring(() => {
|
||||
Application.android.on('activityStarted', (args: any) => {
|
||||
if (!getImageFetcher()) {
|
||||
initImageCache(args.activity);
|
||||
@@ -1376,7 +1377,7 @@ global.NativeScriptGlobals.addEventWiring(() => {
|
||||
});
|
||||
});
|
||||
|
||||
global.NativeScriptGlobals.addEventWiring(() => {
|
||||
getNativeScriptGlobals().addEventWiring(() => {
|
||||
Application.android.on('activityStopped', (args) => {
|
||||
if (getImageFetcher()) {
|
||||
getImageFetcher().closeCache();
|
||||
|
||||
Reference in New Issue
Block a user