@nativescript-community/ui-image 4.3.26 → 4.3.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.3.27](https://github.com/nativescript-community/ui-image/compare/v4.3.26...v4.3.27) (2023-11-24)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-image
9
+
6
10
  ## [4.3.26](https://github.com/nativescript-community/ui-image/compare/v4.3.25...v4.3.26) (2023-11-24)
7
11
 
8
12
  **Note:** Version bump only for package @nativescript-community/ui-image
@@ -10,8 +10,8 @@ export declare class ImagePipeline {
10
10
  isInDiskCache(uri: string | android.net.Uri): boolean;
11
11
  isInBitmapMemoryCache(uri: string | android.net.Uri): boolean;
12
12
  evictFromMemoryCache(uri: string | android.net.Uri): void;
13
- evictFromDiskCache(uri: string | android.net.Uri): void;
14
- evictFromCache(uri: string | android.net.Uri): void;
13
+ evictFromDiskCache(uri: string | android.net.Uri): Promise<void>;
14
+ evictFromCache(uri: string | android.net.Uri): Promise<void>;
15
15
  clearCaches(): void;
16
16
  clearMemoryCaches(): void;
17
17
  clearDiskCaches(): void;
@@ -75,7 +75,7 @@ export declare class Img extends ImageBase {
75
75
  updateViewSize(imageInfo: any): void;
76
76
  disposeNativeView(): void;
77
77
  get cacheKey(): string | globalAndroid.net.Uri;
78
- updateImageUri(): void;
78
+ updateImageUri(): Promise<void>;
79
79
  controllerListener: com.facebook.drawee.controller.ControllerListener<com.facebook.imagepipeline.image.ImageInfo>;
80
80
  protected initImage(): Promise<void>;
81
81
  private updateHierarchy;
package/index.android.js CHANGED
@@ -8,7 +8,7 @@ let initialized = false;
8
8
  let initializeConfig;
9
9
  export function initialize(config) {
10
10
  if (!initialized) {
11
- const context = Utils.ad.getApplicationContext();
11
+ const context = Utils.android.getApplicationContext();
12
12
  if (!context) {
13
13
  initializeConfig = config;
14
14
  return;
@@ -72,7 +72,7 @@ function getUri(src, asNative = true) {
72
72
  if (Utils.isFileOrResourcePath(imagePath)) {
73
73
  if (imagePath.indexOf(Utils.RESOURCE_PREFIX) === 0) {
74
74
  const resName = imagePath.substring(Utils.RESOURCE_PREFIX.length);
75
- const identifier = Utils.ad.resources.getDrawableId(resName);
75
+ const identifier = Utils.android.resources.getDrawableId(resName);
76
76
  if (0 < identifier) {
77
77
  const netUri = new android.net.Uri.Builder().scheme(com.facebook.common.util.UriUtil.LOCAL_RESOURCE_SCHEME).path(java.lang.String.valueOf(identifier)).build();
78
78
  if (asNative) {
@@ -113,10 +113,10 @@ export class ImagePipeline {
113
113
  evictFromMemoryCache(uri) {
114
114
  this._android.evictFromMemoryCache(this.toUri(uri));
115
115
  }
116
- evictFromDiskCache(uri) {
116
+ async evictFromDiskCache(uri) {
117
117
  this._android.evictFromDiskCache(this.toUri(uri));
118
118
  }
119
- evictFromCache(uri) {
119
+ async evictFromCache(uri) {
120
120
  this._android.evictFromCache(this.toUri(uri));
121
121
  }
122
122
  clearCaches() {
@@ -360,14 +360,14 @@ export class Img extends ImageBase {
360
360
  }
361
361
  return undefined;
362
362
  }
363
- updateImageUri() {
363
+ async updateImageUri() {
364
364
  const imagePipeLine = getImagePipeline();
365
365
  const cacheKey = this.cacheKey;
366
366
  const src = this.src;
367
367
  if (cacheKey) {
368
368
  // const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
369
369
  // // if (isInCache) {
370
- imagePipeLine.evictFromCache(cacheKey);
370
+ await imagePipeLine.evictFromCache(cacheKey);
371
371
  // }
372
372
  }
373
373
  this.src = null;
@@ -448,7 +448,7 @@ export class Img extends ImageBase {
448
448
  if (src) {
449
449
  let drawable;
450
450
  if (src instanceof ImageSource) {
451
- drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), src.android);
451
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), src.android);
452
452
  this.updateViewSize(src.android);
453
453
  }
454
454
  else if (Utils.isFontIconURI(src)) {
@@ -457,7 +457,7 @@ export class Img extends ImageBase {
457
457
  // support sync mode only
458
458
  const font = this.style.fontInternal;
459
459
  const color = this.style.color;
460
- drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
460
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
461
461
  }
462
462
  }
463
463
  if (drawable) {
@@ -699,7 +699,7 @@ export class Img extends ImageBase {
699
699
  // support sync mode only
700
700
  const font = this.style.fontInternal;
701
701
  const color = this.style.color;
702
- drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
702
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
703
703
  }
704
704
  }
705
705
  else if (Utils.isFileOrResourcePath(path)) {
@@ -712,7 +712,7 @@ export class Img extends ImageBase {
712
712
  }
713
713
  }
714
714
  else {
715
- drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), path.android);
715
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), path.android);
716
716
  }
717
717
  return drawable;
718
718
  }
@@ -720,14 +720,17 @@ export class Img extends ImageBase {
720
720
  const img = ImageSource.fromFileSync(localFilePath);
721
721
  let drawable = null;
722
722
  if (img) {
723
- drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), img.android);
723
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), img.android);
724
724
  }
725
725
  return drawable;
726
726
  }
727
727
  getDrawableFromResource(resourceName) {
728
- const identifier = Utils.ad.getApplication().getResources().getIdentifier(resourceName.substr(Utils.RESOURCE_PREFIX.length), 'drawable', Utils.ad.getApplication().getPackageName());
728
+ const application = Utils.android.getApplication();
729
+ const resources = application.getResources();
730
+ const identifier = resources.getIdentifier(resourceName.substring(Utils.RESOURCE_PREFIX.length), 'drawable', application.getPackageName());
729
731
  // we return the identifier to allow Fresco to handle memory / caching
730
732
  return identifier;
733
+ // return Utils.android.getApplicationContext().getDrawable(identifier);
731
734
  }
732
735
  startAnimating() {
733
736
  if (this.nativeImageViewProtected) {
package/index.d.ts CHANGED
@@ -55,7 +55,7 @@ export class Img extends View {
55
55
  /**
56
56
  * Removes all images with the specified Uri from the memory or/and disk and reinitialize the 'src'.
57
57
  */
58
- updateImageUri(): void;
58
+ async updateImageUri();
59
59
 
60
60
  /**
61
61
  * Start image animation
@@ -378,12 +378,12 @@ export class ImagePipeline {
378
378
  /**
379
379
  * Removes all images with the specified Uri from disk cache.
380
380
  */
381
- evictFromDiskCache(uri: string): void;
381
+ async evictFromDiskCache(uri: string): void;
382
382
 
383
383
  /**
384
384
  * Removes all images with the specified Uri from all the caches (memory and disk).
385
385
  */
386
- evictFromCache(uri: string): void;
386
+ async evictFromCache(uri: string): void;
387
387
 
388
388
  /**
389
389
  * Clear all the caches (memory and disk).
package/index.ios.d.ts CHANGED
@@ -20,8 +20,8 @@ export declare class ImagePipeline {
20
20
  isInDiskCache(key: string): boolean;
21
21
  isInBitmapMemoryCache(key: string): boolean;
22
22
  evictFromMemoryCache(key: string): void;
23
- evictFromDiskCache(key: string): void;
24
- evictFromCache(key: string): void;
23
+ evictFromDiskCache(key: string): Promise<void>;
24
+ evictFromCache(key: string): Promise<void>;
25
25
  clearCaches(): void;
26
26
  clearMemoryCaches(): void;
27
27
  clearDiskCaches(): void;
@@ -43,7 +43,7 @@ export declare class Img extends ImageBase {
43
43
  createNativeView(): UIImageView;
44
44
  _setNativeClipToBounds(): void;
45
45
  onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
46
- updateImageUri(): void;
46
+ updateImageUri(): Promise<void>;
47
47
  _setNativeImage(nativeImage: UIImage, animated?: boolean): void;
48
48
  private handleImageLoaded;
49
49
  private onLoadProgress;
package/index.ios.js CHANGED
@@ -89,14 +89,15 @@ export class ImagePipeline {
89
89
  evictFromMemoryCache(key) {
90
90
  this.mIos.removeImageFromMemoryForKey(key);
91
91
  }
92
- evictFromDiskCache(key) {
93
- this.mIos.removeImageFromDiskForKey(key);
92
+ async evictFromDiskCache(key) {
93
+ return new Promise((resolve) => {
94
+ this.mIos.removeImageForKeyCacheTypeCompletion(key, 1 /* SDImageCacheType.Disk */, resolve);
95
+ });
94
96
  }
95
- evictFromCache(key) {
96
- // const key = getUri(uri).absoluteString;
97
- this.mIos.removeImageFromDiskForKey(key);
98
- this.mIos.removeImageFromMemoryForKey(key);
99
- // this.mIos.removeImageForKeyWithCompletion(getUri(uri).absoluteString, null);
97
+ async evictFromCache(key) {
98
+ return new Promise((resolve) => {
99
+ this.mIos.removeImageForKeyCacheTypeCompletion(key, 3 /* SDImageCacheType.All */, resolve);
100
+ });
100
101
  }
101
102
  clearCaches() {
102
103
  this.mIos.clearMemory();
@@ -265,10 +266,10 @@ export class Img extends ImageBase {
265
266
  const viewRatio = width / height;
266
267
  if (viewRatio < ratio) {
267
268
  widthMeasureSpec = layout.makeMeasureSpec(width, layout.EXACTLY);
268
- heightMeasureSpec = layout.makeMeasureSpec((width / ratio), layout.EXACTLY);
269
+ heightMeasureSpec = layout.makeMeasureSpec(width / ratio, layout.EXACTLY);
269
270
  }
270
271
  else {
271
- widthMeasureSpec = layout.makeMeasureSpec((height * ratio), layout.EXACTLY);
272
+ widthMeasureSpec = layout.makeMeasureSpec(height * ratio, layout.EXACTLY);
272
273
  heightMeasureSpec = layout.makeMeasureSpec(height, layout.EXACTLY);
273
274
  }
274
275
  }
@@ -278,18 +279,18 @@ export class Img extends ImageBase {
278
279
  }
279
280
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
280
281
  }
281
- updateImageUri() {
282
+ async updateImageUri() {
282
283
  const imagePipeLine = getImagePipeline();
283
284
  const src = this.src;
284
285
  if (!(src instanceof ImageSource)) {
285
286
  const cachekKey = this.mCacheKey || getUri(src).absoluteString;
286
287
  // const isInCache = imagePipeLine.isInBitmapMemoryCache(cachekKey);
287
288
  // if (isInCache) {
288
- imagePipeLine.evictFromCache(cachekKey);
289
+ await imagePipeLine.evictFromCache(cachekKey);
289
290
  // }
290
291
  }
291
292
  this.src = null;
292
- // ensure we clear the image as
293
+ // ensure we clear the image as
293
294
  this._setNativeImage(null, false);
294
295
  this.src = src;
295
296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.3.26",
3
+ "version": "4.3.27",
4
4
  "description": "Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.",
5
5
  "main": "./index",
6
6
  "sideEffects": false,
@@ -44,5 +44,5 @@
44
44
  },
45
45
  "license": "Apache-2.0",
46
46
  "readmeFilename": "README.md",
47
- "gitHead": "2830ed62627e85464ad0c79fdb2bc1b20cae0255"
47
+ "gitHead": "8bcab12e0d0379c7d61036dbed2eb3eb9e3df512"
48
48
  }