mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
refactor: circular deps part 13
This commit is contained in:
@ -1,12 +1,9 @@
|
||||
// Definitions.
|
||||
import { ImageSource as ImageSourceDefinition, iosSymbolScaleType } from '.';
|
||||
import { ImageAsset } from '../image-asset';
|
||||
import * as http from '../http';
|
||||
|
||||
// Types.
|
||||
import { path as fsPath, knownFolders } from '../file-system';
|
||||
import { isFileOrResourcePath, RESOURCE_PREFIX, layout } from '../utils';
|
||||
import { Application } from '../application';
|
||||
import { getNativeApp } from '../application/helpers-common';
|
||||
import { Font } from '../ui/styling/font';
|
||||
import { Color } from '../color';
|
||||
|
||||
@ -14,23 +11,8 @@ import { getScaledDimensions } from './image-source-common';
|
||||
|
||||
export { isFileOrResourcePath };
|
||||
|
||||
let application: android.app.Application;
|
||||
let resources: android.content.res.Resources;
|
||||
|
||||
function getApplication() {
|
||||
if (!application) {
|
||||
application = Application.android.getNativeApplication();
|
||||
}
|
||||
|
||||
return application;
|
||||
}
|
||||
|
||||
function getResources() {
|
||||
if (!resources) {
|
||||
resources = getApplication().getResources();
|
||||
}
|
||||
|
||||
return resources;
|
||||
return getNativeApp() as android.app.Application;
|
||||
}
|
||||
|
||||
export class ImageSource implements ImageSourceDefinition {
|
||||
@ -85,7 +67,7 @@ export class ImageSource implements ImageSourceDefinition {
|
||||
}
|
||||
|
||||
static fromResourceSync(name: string): ImageSource {
|
||||
const res = getResources();
|
||||
const res = getApplication().getResources();
|
||||
if (res) {
|
||||
const identifier: number = res.getIdentifier(name, 'drawable', getApplication().getPackageName());
|
||||
if (0 < identifier) {
|
||||
|
Reference in New Issue
Block a user