Remove the header dependency of SDWebImageManager of SDWebImageDownloader. Use SDImageLoaderProgressBlock instead of SDWebImageDownloadProgressBlock

This commit is contained in:
DreamPiggy 2018-05-17 14:04:57 +08:00
parent f96c94ef7d
commit 4eb13bf2a1
18 changed files with 47 additions and 47 deletions

View File

@ -153,7 +153,7 @@
- (void)sd_setImageWithURL:(nullable NSURL *)url - (void)sd_setImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
@end @end

View File

@ -80,7 +80,7 @@
[self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
} }
- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDExternalCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDImageLoaderProgressBlock)progressBlock completed:(SDExternalCompletionBlock)completedBlock {
[self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
} }
@ -88,7 +88,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
dispatch_group_t group = dispatch_group_create(); dispatch_group_t group = dispatch_group_create();
SDWebImageMutableContext *mutableContext; SDWebImageMutableContext *mutableContext;

View File

@ -123,7 +123,7 @@
- (void)sd_setImageWithURL:(nullable NSURL *)url - (void)sd_setImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
/** /**
@ -147,7 +147,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
@end @end

View File

@ -40,7 +40,7 @@
[self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
} }
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
} }
@ -48,7 +48,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
[self sd_internalSetImageWithURL:url [self sd_internalSetImageWithURL:url

View File

@ -125,7 +125,7 @@
- (void)sd_setImageWithURL:(nullable NSURL *)url - (void)sd_setImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
/** /**
@ -149,7 +149,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
#pragma mark - Alternate Image #pragma mark - Alternate Image
@ -263,7 +263,7 @@
- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url - (void)sd_setAlternateImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
/** /**
@ -287,7 +287,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
#pragma mark - Cancel #pragma mark - Cancel

View File

@ -44,7 +44,7 @@ static NSString * const SDAlternateImageOperationKey = @"NSButtonAlternateImageO
[self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
} }
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
} }
@ -52,7 +52,7 @@ static NSString * const SDAlternateImageOperationKey = @"NSButtonAlternateImageO
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
self.sd_currentImageURL = url; self.sd_currentImageURL = url;
[self sd_internalSetImageWithURL:url [self sd_internalSetImageWithURL:url
@ -94,7 +94,7 @@ static NSString * const SDAlternateImageOperationKey = @"NSButtonAlternateImageO
[self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
} }
- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
} }
@ -102,7 +102,7 @@ static NSString * const SDAlternateImageOperationKey = @"NSButtonAlternateImageO
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
self.sd_currentAlternateImageURL = url; self.sd_currentAlternateImageURL = url;

View File

@ -118,7 +118,7 @@
- (void)sd_setImageWithURL:(nullable NSURL *)url - (void)sd_setImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
/** /**
@ -142,7 +142,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
@end @end

View File

@ -39,7 +39,7 @@
[self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
} }
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
} }
@ -47,7 +47,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
Class animatedImageClass = [SDAnimatedImage class]; Class animatedImageClass = [SDAnimatedImage class];
SDWebImageMutableContext *mutableContext; SDWebImageMutableContext *mutableContext;

View File

@ -9,11 +9,10 @@
#import "SDWebImageCompat.h" #import "SDWebImageCompat.h"
#import "SDWebImageOperation.h" #import "SDWebImageOperation.h"
#import "SDImageCacheDefine.h" #import "SDImageCacheDefine.h"
#import "SDWebImageDownloader.h" #import "SDImageLoader.h"
#import "SDImageTransformer.h" #import "SDImageTransformer.h"
#import "SDWebImageCacheKeyFilter.h" #import "SDWebImageCacheKeyFilter.h"
#import "SDWebImageCacheSerializer.h" #import "SDWebImageCacheSerializer.h"
#import "SDImageLoader.h"
typedef void(^SDExternalCompletionBlock)(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL); typedef void(^SDExternalCompletionBlock)(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL);
@ -204,7 +203,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
*/ */
- (nullable SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url - (nullable SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nonnull SDInternalCompletionBlock)completedBlock; completed:(nonnull SDInternalCompletionBlock)completedBlock;
/** /**
@ -222,7 +221,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
- (nullable SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url - (nullable SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nonnull SDInternalCompletionBlock)completedBlock; completed:(nonnull SDInternalCompletionBlock)completedBlock;
/** /**

View File

@ -8,9 +8,8 @@
#import "SDWebImageManager.h" #import "SDWebImageManager.h"
#import "SDImageCache.h" #import "SDImageCache.h"
#import "NSImage+Compatibility.h" #import "SDWebImageDownloader.h"
#import "UIImage+WebCache.h" #import "UIImage+WebCache.h"
#import "SDAnimatedImage.h"
#import "SDWebImageError.h" #import "SDWebImageError.h"
#define LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER); #define LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER);
@ -116,14 +115,14 @@ static id<SDImageLoader> _defaultImageLoader;
return SDScaledImageForKey(key, image); return SDScaledImageForKey(key, image);
} }
- (SDWebImageCombinedOperation *)loadImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDInternalCompletionBlock)completedBlock { - (SDWebImageCombinedOperation *)loadImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDImageLoaderProgressBlock)progressBlock completed:(SDInternalCompletionBlock)completedBlock {
return [self loadImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock]; return [self loadImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock];
} }
- (SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url - (SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nonnull SDInternalCompletionBlock)completedBlock { completed:(nonnull SDInternalCompletionBlock)completedBlock {
// Invoking this method without a completedBlock is pointless // Invoking this method without a completedBlock is pointless
NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead"); NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead");
@ -188,7 +187,7 @@ static id<SDImageLoader> _defaultImageLoader;
url:(nullable NSURL *)url url:(nullable NSURL *)url
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDInternalCompletionBlock)completedBlock { completed:(nullable SDInternalCompletionBlock)completedBlock {
// Check whether we should query cache // Check whether we should query cache
BOOL shouldQueryCache = (options & SDWebImageFromLoaderOnly) == 0; BOOL shouldQueryCache = (options & SDWebImageFromLoaderOnly) == 0;
@ -218,7 +217,7 @@ static id<SDImageLoader> _defaultImageLoader;
cachedImage:(nullable UIImage *)cachedImage cachedImage:(nullable UIImage *)cachedImage
cachedData:(nullable NSData *)cachedData cachedData:(nullable NSData *)cachedData
cacheType:(SDImageCacheType)cacheType cacheType:(SDImageCacheType)cacheType
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDInternalCompletionBlock)completedBlock { completed:(nullable SDInternalCompletionBlock)completedBlock {
// Check whether we should download image from network // Check whether we should download image from network
BOOL shouldDownload = (options & SDWebImageFromCacheOnly) == 0; BOOL shouldDownload = (options & SDWebImageFromCacheOnly) == 0;

View File

@ -149,7 +149,7 @@
forState:(UIControlState)state forState:(UIControlState)state
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
/** /**
@ -175,7 +175,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
#pragma mark - Background Image #pragma mark - Background Image
@ -308,7 +308,7 @@
forState:(UIControlState)state forState:(UIControlState)state
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
/** /**
@ -333,7 +333,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
#pragma mark - Cancel #pragma mark - Cancel

View File

@ -76,7 +76,7 @@ static inline NSString * backgroundImageOperationKeyForState(UIControlState stat
[self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options progress:nil completed:completedBlock]; [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options progress:nil completed:completedBlock];
} }
- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
} }
@ -85,7 +85,7 @@ static inline NSString * backgroundImageOperationKeyForState(UIControlState stat
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
if (!url) { if (!url) {
[self.sd_imageURLStorage removeObjectForKey:imageURLKeyForState(state)]; [self.sd_imageURLStorage removeObjectForKey:imageURLKeyForState(state)];
@ -156,7 +156,7 @@ static inline NSString * backgroundImageOperationKeyForState(UIControlState stat
[self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 progress:nil completed:completedBlock];
} }
- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 context:nil progress:progressBlock completed:completedBlock]; [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 context:nil progress:progressBlock completed:completedBlock];
} }
@ -165,7 +165,7 @@ static inline NSString * backgroundImageOperationKeyForState(UIControlState stat
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
if (!url) { if (!url) {
[self.sd_imageURLStorage removeObjectForKey:backgroundImageURLKeyForState(state)]; [self.sd_imageURLStorage removeObjectForKey:backgroundImageURLKeyForState(state)];

View File

@ -86,7 +86,7 @@
*/ */
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
@end @end

View File

@ -33,14 +33,14 @@ static NSString * const SDHighlightedImageOperationKey = @"UIImageViewImageOpera
[self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock];
} }
- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDExternalCompletionBlock)completedBlock { - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDImageLoaderProgressBlock)progressBlock completed:(SDExternalCompletionBlock)completedBlock {
[self sd_setHighlightedImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setHighlightedImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock];
} }
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
__weak typeof(self)weakSelf = self; __weak typeof(self)weakSelf = self;
SDWebImageMutableContext *mutableContext; SDWebImageMutableContext *mutableContext;

View File

@ -148,7 +148,7 @@
- (void)sd_setImageWithURL:(nullable NSURL *)url - (void)sd_setImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
/** /**
@ -172,7 +172,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock; completed:(nullable SDExternalCompletionBlock)completedBlock;
#if SD_UIKIT #if SD_UIKIT

View File

@ -37,7 +37,7 @@
[self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
} }
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
} }
@ -45,7 +45,7 @@
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock { completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_internalSetImageWithURL:url [self sd_internalSetImageWithURL:url
placeholderImage:placeholder placeholderImage:placeholder

View File

@ -66,7 +66,7 @@ typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable ima
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
setImageBlock:(nullable SDSetImageBlock)setImageBlock setImageBlock:(nullable SDSetImageBlock)setImageBlock
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDInternalCompletionBlock)completedBlock; completed:(nullable SDInternalCompletionBlock)completedBlock;
/** /**

View File

@ -40,7 +40,9 @@ const int64_t SDWebImageProgressUnitCountUnknown = 1LL;
placeholderImage:(nullable UIImage *)placeholder placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context context:(nullable SDWebImageContext *)context
setImageBlock:(nullable SDSetImageBlock)setImageBlock progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDInternalCompletionBlock)completedBlock { setImageBlock:(nullable SDSetImageBlock)setImageBlock
progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDInternalCompletionBlock)completedBlock {
context = [context copy]; // copy to avoid mutable object context = [context copy]; // copy to avoid mutable object
NSString *validOperationKey = nil; NSString *validOperationKey = nil;
if ([context valueForKey:SDWebImageContextSetImageOperationKey]) { if ([context valueForKey:SDWebImageContextSetImageOperationKey]) {
@ -90,7 +92,7 @@ const int64_t SDWebImageProgressUnitCountUnknown = 1LL;
} }
__weak __typeof(self)wself = self; __weak __typeof(self)wself = self;
SDWebImageDownloaderProgressBlock combinedProgressBlock = ^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) { SDImageLoaderProgressBlock combinedProgressBlock = ^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
__strong __typeof (wself) sself = wself; __strong __typeof (wself) sself = wself;
NSProgress *imageProgress = sself.sd_imageProgress; NSProgress *imageProgress = sself.sd_imageProgress;
imageProgress.totalUnitCount = expectedSize; imageProgress.totalUnitCount = expectedSize;