@@ -372,37 +372,6 @@ export class ImageInfo implements ImageInfoBase {
372372 }
373373}
374374
375- export const needUpdateHierarchy = function ( targetOrNeedsLayout : any , propertyKey ?: string | symbol , descriptor ?: PropertyDescriptor ) : any {
376- if ( typeof targetOrNeedsLayout === 'boolean' ) {
377- return function ( target2 : any , propertyKey : string | symbol , descriptor : PropertyDescriptor ) {
378- const originalMethod = descriptor . value ;
379- descriptor . value = function ( ...args : any [ ] ) {
380- if ( ! this . mCanUpdateHierarchy ) {
381- this . mNeedUpdateHierarchy = true ;
382- if ( this . isLoaded && targetOrNeedsLayout ) {
383- const layoutParams = ( this . nativeViewProtected as android . widget . ImageView ) ?. getLayoutParams ( ) ;
384- if ( layoutParams ) {
385- if ( layout . getMeasureSpecMode ( layoutParams . height ) !== layout . EXACTLY || layout . getMeasureSpecMode ( layoutParams . width ) !== layout . EXACTLY ) {
386- this . mNeedUpdateLayout = true ;
387- }
388- }
389- }
390- return ;
391- }
392- return originalMethod . apply ( this , args ) ;
393- } ;
394- } ;
395- }
396- const originalMethod = descriptor . value ;
397- descriptor . value = function ( ...args : any [ ] ) {
398- if ( ! this . mCanUpdateHierarchy ) {
399- this . mNeedUpdateHierarchy = true ;
400- return ;
401- }
402- return originalMethod . apply ( this , args ) ;
403- } ;
404- } ;
405-
406375export class Img extends ImageBase {
407376 //TODO: remove as it needs to be added after TS 5.7 change https://github.com/microsoft/TypeScript/pull/59860
408377 [ key : symbol ] : ( ...args : any [ ] ) => any | void ;
@@ -413,29 +382,13 @@ export class Img extends ImageBase {
413382 //@ts -expect-error just for declaration
414383 nativeImageViewProtected : com . nativescript . image . MatrixImageView ;
415384
416- mCanUpdateHierarchy = true ;
417- mNeedUpdateHierarchy = false ;
418385 mNeedUpdateLayout = false ;
419386
420387 private currentTarget : any = null ;
421388 private isNetworkRequest = false ;
422389 private progressCallback : any = null ;
423390 private loadSourceCallback : any = null ;
424391
425- public onResumeNativeUpdates ( ) : void {
426- this . mCanUpdateHierarchy = false ;
427- super . onResumeNativeUpdates ( ) ;
428- this . mCanUpdateHierarchy = true ;
429- if ( this . mNeedUpdateHierarchy ) {
430- this . mNeedUpdateHierarchy = false ;
431- this . updateHierarchy ( ) ;
432- }
433- if ( this . mNeedUpdateLayout ) {
434- this . mNeedUpdateLayout = false ;
435- this . nativeViewProtected . requestLayout ( ) ;
436- }
437- }
438-
439392 public createNativeView ( ) {
440393 if ( ! initialized ) {
441394 initialize ( ) ;
@@ -469,15 +422,11 @@ export class Img extends ImageBase {
469422 this . initImage ( ) ;
470423 }
471424
472- @needUpdateHierarchy
473- [ placeholderImageUriProperty . setNative ] ( ) {
474- this . updateHierarchy ( ) ;
475- }
425+ @needRequestImage
426+ [ placeholderImageUriProperty . setNative ] ( ) { }
476427
477- @needUpdateHierarchy
478- [ failureImageUriProperty . setNative ] ( ) {
479- this . updateHierarchy ( ) ;
480- }
428+ @needRequestImage
429+ [ failureImageUriProperty . setNative ] ( ) { }
481430
482431 [ stretchProperty . setNative ] ( ) {
483432 // Scale type
@@ -489,44 +438,30 @@ export class Img extends ImageBase {
489438 }
490439 }
491440
492- @needUpdateHierarchy
493- [ fadeDurationProperty . setNative ] ( ) {
494- this . updateHierarchy ( ) ;
495- }
441+ @needRequestImage
442+ [ fadeDurationProperty . setNative ] ( ) { }
496443
497- @needUpdateHierarchy
498- [ backgroundUriProperty . setNative ] ( ) {
499- this . updateHierarchy ( ) ;
500- }
444+ @needRequestImage
445+ [ backgroundUriProperty . setNative ] ( ) { }
501446
502- @needUpdateHierarchy
503- [ roundAsCircleProperty . setNative ] ( value ) {
504- this . updateHierarchy ( ) ;
505- }
447+ @needRequestImage
448+ [ roundAsCircleProperty . setNative ] ( value ) { }
506449
507- @needUpdateHierarchy
508- [ roundTopLeftRadiusProperty . setNative ] ( ) {
509- this . updateHierarchy ( ) ;
510- }
450+ @needRequestImage
451+ [ roundTopLeftRadiusProperty . setNative ] ( ) { }
511452
512453 [ imageRotationProperty . setNative ] ( value ) {
513454 this . nativeImageViewProtected ?. setImageRotation ( value ) ;
514455 }
515456
516- @needUpdateHierarchy
517- [ roundTopRightRadiusProperty . setNative ] ( ) {
518- this . updateHierarchy ( ) ;
519- }
457+ @needRequestImage
458+ [ roundTopRightRadiusProperty . setNative ] ( ) { }
520459
521- @needUpdateHierarchy
522- [ roundBottomLeftRadiusProperty . setNative ] ( ) {
523- this . updateHierarchy ( ) ;
524- }
460+ @needRequestImage
461+ [ roundBottomLeftRadiusProperty . setNative ] ( ) { }
525462
526- @needUpdateHierarchy
527- [ roundBottomRightRadiusProperty . setNative ] ( ) {
528- this . updateHierarchy ( ) ;
529- }
463+ @needRequestImage
464+ [ roundBottomRightRadiusProperty . setNative ] ( ) { }
530465
531466 [ tintColorProperty . setNative ] ( value : Color ) {
532467 if ( this . nativeImageViewProtected ) {
@@ -535,44 +470,29 @@ export class Img extends ImageBase {
535470 }
536471
537472 @needRequestImage
538- [ blurRadiusProperty . setNative ] ( value ) {
539- this . initImage ( ) ;
540- }
473+ [ blurRadiusProperty . setNative ] ( value ) { }
541474
542475 @needRequestImage
543- [ srcProperty . setNative ] ( ) {
544- this . initImage ( ) ;
545- }
476+ [ srcProperty . setNative ] ( ) { }
546477 @needRequestImage
547- [ decodeWidthProperty . setNative ] ( ) {
548- this . initImage ( ) ;
549- }
478+ [ decodeWidthProperty . setNative ] ( ) { }
550479 @needRequestImage
551- [ decodeHeightProperty . setNative ] ( ) {
552- this . initImage ( ) ;
553- }
480+ [ decodeHeightProperty . setNative ] ( ) { }
554481
555482 @needRequestImage
556- [ lowerResSrcProperty . setNative ] ( ) {
557- this . initImage ( ) ;
558- }
483+ [ lowerResSrcProperty . setNative ] ( ) { }
559484
560485 @needRequestImage
561- [ blurDownSamplingProperty . setNative ] ( ) {
562- this . initImage ( ) ;
563- }
486+ [ blurDownSamplingProperty . setNative ] ( ) { }
564487
565- @needRequestImage
566488 [ aspectRatioProperty . setNative ] ( value ) {
567489 if ( this . nativeViewProtected ) {
568490 this . nativeViewProtected . setAspectRatio ( value || 0 ) ;
569491 }
570492 }
571493
572494 @needRequestImage
573- [ headersProperty . setNative ] ( value ) {
574- this . initImage ( ) ;
575- }
495+ [ headersProperty . setNative ] ( value ) { }
576496
577497 [ backgroundInternalProperty . setNative ] ( value : Background ) {
578498 super [ backgroundInternalProperty . setNative ] ( value ) ;
@@ -1007,18 +927,6 @@ export class Img extends ImageBase {
1007927 }
1008928 }
1009929
1010- private updateHierarchy ( ) {
1011- if ( ! this . mCanUpdateHierarchy ) {
1012- this . mNeedUpdateHierarchy = true ;
1013- return ;
1014- }
1015-
1016- // Force reload with new settings
1017- if ( this . nativeImageViewProtected && this . src ) {
1018- this . initImage ( ) ;
1019- }
1020- }
1021-
1022930 private getDrawable ( path : string | ImageSource ) : android . graphics . drawable . Drawable | number {
1023931 if ( typeof path === 'string' ) {
1024932 if ( Utils . isFontIconURI ( path ) ) {
0 commit comments