@@ -459,6 +459,7 @@ export class Img extends ImageBase {
459459
460460 public disposeNativeView ( ) {
461461 this . controllerListener = null ;
462+ this . requestListener = null ;
462463 // this.nativeImageViewProtected.setImageURI(null, null);
463464 }
464465 get cacheKey ( ) {
@@ -608,6 +609,7 @@ export class Img extends ImageBase {
608609 // }
609610
610611 controllerListener : com . facebook . drawee . controller . ControllerListener < com . facebook . imagepipeline . image . ImageInfo > ;
612+ requestListener : com . facebook . imagepipeline . listener . RequestListener ;
611613
612614 protected async handleImageSrc ( src : SrcType ) {
613615 const view = this . nativeViewProtected ;
@@ -769,6 +771,41 @@ export class Img extends ImageBase {
769771 }
770772 } ) ;
771773 }
774+ if ( ! this . requestListener && this . hasListeners ( ImageBase . fetchingFromEvent ) ) {
775+ const that : WeakRef < Img > = new WeakRef ( this ) ;
776+ this . requestListener = new com . facebook . imagepipeline . listener . RequestListener ( {
777+ onRequestStart ( request , callerContext , requestId , isPrefetch ) {
778+
779+ } ,
780+ onRequestSuccess ( param0 : com . facebook . imagepipeline . request . ImageRequest , param1 : string , param2 : boolean ) { } ,
781+ onRequestFailure ( param0 : com . facebook . imagepipeline . request . ImageRequest , param1 : string , param2 : java . lang . Throwable , param3 : boolean ) { } ,
782+ onRequestCancellation ( param0 : string ) { } ,
783+ onProducerStart ( param0 : string , param1 : string ) { } ,
784+ onProducerEvent ( param0 : string , param1 : string , param2 : string ) { } ,
785+ onProducerFinishWithSuccess ( requestId : string , producerName : string , extraMap : java . util . Map < string , string > ) {
786+ console . log ( 'onProducerFinishWithSuccess' , producerName )
787+ const owner = that ?. get ( ) ;
788+ const eventName = ImageBase . fetchingFromEvent ;
789+
790+ if ( owner ?. hasListeners ( eventName ) ) {
791+ let source = 'local' ;
792+ if ( producerName . indexOf ( 'Network' ) !== - 1 ) {
793+ source = 'network'
794+ } else if ( producerName . indexOf ( 'Cache' ) !== - 1 ) {
795+ source = 'cache'
796+ }
797+ owner . notify ( {
798+ eventName,
799+ source
800+ } ) ;
801+ }
802+ } ,
803+ onProducerFinishWithFailure ( param0 : string , param1 : string , param2 : java . lang . Throwable , param3 : java . util . Map < string , string > ) { } ,
804+ onProducerFinishWithCancellation ( param0 : string , param1 : string , param2 : java . util . Map < string , string > ) { } ,
805+ onUltimateProducerReached ( param0 : string , param1 : string , param2 : boolean ) { } ,
806+ requiresExtraMap ( param0 : string ) { return false } ,
807+ } )
808+ }
772809 const options = JSON . stringify ( {
773810 progressiveRenderingEnabled : this . blurRadius ,
774811 localThumbnailPreviewsEnabled : this . blurRadius ,
@@ -781,7 +818,7 @@ export class Img extends ImageBase {
781818 tapToRetryEnabled : this . tapToRetryEnabled ,
782819 headers : this . headers
783820 } ) ;
784- view . setUri ( uri , options , this . controllerListener ) ;
821+ view . setUri ( uri , options , this . controllerListener , this . requestListener ) ;
785822 // const async = this.loadMode === 'async';
786823 // if (async) {
787824 // const builder = com.facebook.drawee.backends.pipeline.Fresco.newDraweeControllerBuilder();
0 commit comments