()
| 32 | private _cache: android.util.LruCache<string, android.graphics.Bitmap>; |
| 33 | |
| 34 | constructor() { |
| 35 | super(); |
| 36 | |
| 37 | ensureLruBitmapCacheClass(); |
| 38 | const maxMemory = java.lang.Runtime.getRuntime().maxMemory() / 1024; |
| 39 | const cacheSize = maxMemory / 8; |
| 40 | this._cache = new LruBitmapCacheClass(cacheSize); |
| 41 | |
| 42 | const that = new WeakRef(this); |
| 43 | this._callback = new org.nativescript.widgets.Async.CompleteCallback({ |
| 44 | onComplete: function (result: any, context: any) { |
| 45 | const instance = that?.get(); |
| 46 | if (instance) { |
| 47 | if (result) { |
| 48 | instance._onDownloadCompleted(context, result); |
| 49 | } else { |
| 50 | instance._onDownloadError(context, new Error('No result in CompletionCallback')); |
| 51 | } |
| 52 | } |
| 53 | }, |
| 54 | onError: function (err: string, context: any) { |
| 55 | const instance = that?.get(); |
| 56 | if (instance) { |
| 57 | instance._onDownloadError(context, new Error(err)); |
| 58 | } |
| 59 | }, |
| 60 | }); |
| 61 | } |
| 62 | |
| 63 | public _downloadCore(request: common.DownloadRequest) { |
| 64 | org.nativescript.widgets.Async.Image.download(request.url, this._callback, request.key); |
nothing calls this directly
no test coverage detected