@@ -156,7 +156,10 @@ function getUIImageScaleType(scaleType: string) {
156156 return null ;
157157}
158158
159- export function initialize ( config ?: ImagePipelineConfigSetting ) : void { }
159+ export function initialize ( config ?: ImagePipelineConfigSetting ) : void {
160+ SDImageLoadersManager . sharedManager . loaders = NSArray . arrayWithArray ( [ SDWebImageDownloader . sharedDownloader , SDImagePhotosLoader . sharedLoader ] ) ;
161+
162+ }
160163export function shutDown ( ) : void { }
161164
162165export class ImagePipeline {
@@ -166,23 +169,23 @@ export class ImagePipeline {
166169 }
167170
168171 isInDiskCache ( uri : string ) : boolean {
169- return this . _ios . diskImageDataExistsWithKey ( uri ) ;
172+ return this . _ios . diskImageDataExistsWithKey ( getUri ( uri ) . absoluteString ) ;
170173 }
171174
172175 isInBitmapMemoryCache ( uri : string ) : boolean {
173- return this . _ios . imageFromMemoryCacheForKey ( uri ) !== null ;
176+ return this . _ios . imageFromMemoryCacheForKey ( getUri ( uri ) . absoluteString ) !== null ;
174177 }
175178
176179 evictFromMemoryCache ( uri : string ) : void {
177- this . _ios . removeImageFromMemoryForKey ( uri ) ;
180+ this . _ios . removeImageFromMemoryForKey ( getUri ( uri ) . absoluteString ) ;
178181 }
179182
180183 evictFromDiskCache ( uri : string ) : void {
181- this . _ios . removeImageFromDiskForKey ( uri ) ;
184+ this . _ios . removeImageFromDiskForKey ( getUri ( uri ) . absoluteString ) ;
182185 }
183186
184187 evictFromCache ( uri : string ) : void {
185- this . _ios . removeImageForKeyWithCompletion ( uri , null ) ;
188+ this . _ios . removeImageForKeyWithCompletion ( getUri ( uri ) . absoluteString , null ) ;
186189 }
187190
188191 clearCaches ( ) {
@@ -232,9 +235,10 @@ export function getImagePipeline(): ImagePipeline {
232235}
233236
234237function getUri ( src : string | ImageAsset ) {
238+ console . log ( 'getUri' , src ) ;
235239 let uri : any = src ;
236240 if ( src instanceof ImageAsset ) {
237- uri = src . ios ;
241+ uri = NSURL . sd_URLWithAsset ( src . ios ) ;
238242 }
239243 if ( uri . indexOf ( RESOURCE_PREFIX ) === 0 ) {
240244 const resName = uri . substr ( RESOURCE_PREFIX . length ) ;
@@ -251,9 +255,9 @@ function getUri(src: string | ImageAsset) {
251255 return false ;
252256 } ) ;
253257 } else if ( uri . indexOf ( '~/' ) === 0 ) {
254- uri = NSURL . alloc ( ) . initFileURLWithPath ( `${ path . join ( knownFolders . currentApp ( ) . path , uri . replace ( '~/' , '' ) ) } ` ) ;
258+ return NSURL . alloc ( ) . initFileURLWithPath ( `${ path . join ( knownFolders . currentApp ( ) . path , uri . replace ( '~/' , '' ) ) } ` ) ;
255259 }
256- return uri ;
260+ return NSURL . URLWithString ( uri ) ;
257261}
258262
259263export class Img extends ImageBase {
@@ -332,7 +336,7 @@ export class Img extends ImageBase {
332336 const imagePipeLine = getImagePipeline ( ) ;
333337 const src = this . src ;
334338 if ( ! ( src instanceof ImageSource ) ) {
335- const uri = getUri ( src ) ;
339+ const uri = getUri ( src ) . absoluteString ;
336340 const isInCache = imagePipeLine . isInBitmapMemoryCache ( uri ) ;
337341 if ( isInCache ) {
338342 imagePipeLine . evictFromCache ( uri ) ;
@@ -464,12 +468,13 @@ export class Img extends ImageBase {
464468 return ;
465469 }
466470
471+ const uri = getUri ( src ) ;
467472 if ( this . noCache ) {
468- const uri = getUri ( src ) ;
473+ const key = uri . absoluteString ;
469474 const imagePipeLine = getImagePipeline ( ) ;
470- const isInCache = imagePipeLine . isInBitmapMemoryCache ( uri ) ;
475+ const isInCache = imagePipeLine . isInBitmapMemoryCache ( key ) ;
471476 if ( isInCache ) {
472- imagePipeLine . evictFromCache ( uri ) ;
477+ imagePipeLine . evictFromCache ( key ) ;
473478 }
474479 }
475480 this . isLoading = true ;
@@ -519,7 +524,7 @@ export class Img extends ImageBase {
519524 // console.log('about to load', this.src, options);
520525 this . nativeViewProtected . sd_setImageWithURLPlaceholderImageOptionsContextProgressCompleted (
521526 getUri ( src ) ,
522- this . getUIImage ( this . placeholderImageUri ) ,
527+ this . placeholderImage ,
523528 options ,
524529 context ,
525530 this . onLoadProgress ,
@@ -533,7 +538,9 @@ export class Img extends ImageBase {
533538 [ ImageBase . srcProperty . setNative ] ( value ) {
534539 this . initImage ( ) ;
535540 }
541+ placeholderImage : UIImage ;
536542 [ ImageBase . placeholderImageUriProperty . setNative ] ( ) {
543+ this . placeholderImage = this . getUIImage ( this . placeholderImageUri ) ;
537544 this . initImage ( ) ;
538545 }
539546
0 commit comments