mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor(core): zero circulars + esm ready (#10770)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { IFileSystemAccess, FileSystemAccess, FileSystemAccess29 } from './file-system-access';
|
||||
import { SDK_VERSION } from '../utils';
|
||||
import { Application } from '../application';
|
||||
import { SDK_VERSION } from '../utils/constants';
|
||||
import { getNativeApp } from '../application/helpers-common';
|
||||
|
||||
// The FileSystemAccess implementation, used through all the APIs.
|
||||
let fileAccess: IFileSystemAccess;
|
||||
@@ -182,15 +182,6 @@ export class FileSystemEntity {
|
||||
}
|
||||
}
|
||||
|
||||
let applicationContext;
|
||||
function getApplicationContext() {
|
||||
if (!applicationContext) {
|
||||
applicationContext = Application.android.getNativeApplication().getApplicationContext();
|
||||
}
|
||||
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
export enum AndroidDirectory {
|
||||
ALARMS = 'alarms',
|
||||
AUDIOBOOKS = 'audiobooks',
|
||||
@@ -279,7 +270,7 @@ class Android {
|
||||
throw new Error(`createFile is available on Android only!`);
|
||||
}
|
||||
|
||||
const context = getApplicationContext() as android.content.Context;
|
||||
const context = getNativeApp<android.app.Application>().getApplicationContext() as android.content.Context;
|
||||
|
||||
const meta = new android.content.ContentValues();
|
||||
meta.put(android.provider.MediaStore.MediaColumns.DISPLAY_NAME, options.name);
|
||||
@@ -332,7 +323,7 @@ export class File extends FileSystemEntity {
|
||||
// falls back to creating a temp file without a known extension.
|
||||
if (!fileInfo) {
|
||||
const tempFile = `${knownFolders.temp().path}/${java.util.UUID.randomUUID().toString()}`;
|
||||
org.nativescript.widgets.Async.File.copySync(path, tempFile, getApplicationContext());
|
||||
org.nativescript.widgets.Async.File.copySync(path, tempFile, getNativeApp<android.app.Application>().getApplicationContext());
|
||||
path = tempFile;
|
||||
} else {
|
||||
const ext = fileInfo.extension;
|
||||
|
||||
Reference in New Issue
Block a user