UNPKG

1.22 kBJavaScriptView Raw
1import { ImageAssetBase } from './image-asset-common';
2import { path as fsPath, knownFolders } from '../file-system';
3import { ad } from '../utils';
4import { Screen } from '../platform';
5export * from './image-asset-common';
6export class ImageAsset extends ImageAssetBase {
7 constructor(asset) {
8 super();
9 let fileName = typeof asset === 'string' ? asset.trim() : '';
10 if (fileName.indexOf('~/') === 0) {
11 fileName = fsPath.join(knownFolders.currentApp().path, fileName.replace('~/', ''));
12 }
13 this.android = fileName;
14 }
15 // @ts-ignore
16 get android() {
17 return this._android;
18 }
19 set android(value) {
20 this._android = value;
21 }
22 getImageAsync(callback) {
23 org.nativescript.widgets.Utils.loadImageAsync(ad.getApplicationContext(), this.android, JSON.stringify(this.options || {}), Screen.mainScreen.widthPixels, Screen.mainScreen.heightPixels, new org.nativescript.widgets.Utils.AsyncImageCallback({
24 onSuccess(bitmap) {
25 callback(bitmap, null);
26 },
27 onError(ex) {
28 callback(null, ex);
29 },
30 }));
31 }
32}
33//# sourceMappingURL=index.android.js.map
\No newline at end of file