1 | import { ImageAssetBase } from './image-asset-common';
|
2 | import { path as fsPath, knownFolders } from '../file-system';
|
3 | import { ad } from '../utils';
|
4 | import { Screen } from '../platform';
|
5 | export * from './image-asset-common';
|
6 | export 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 |
|
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 |
|
\ | No newline at end of file |