...
|
...
|
@@ -20,6 +20,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; |
|
|
|
|
|
@property (strong, nonatomic) NSOperationQueue *downloadQueue;
|
|
|
@property (weak, nonatomic) NSOperation *lastAddedOperation;
|
|
|
@property (assign, nonatomic) Class operationClass;
|
|
|
@property (strong, nonatomic) NSMutableDictionary *URLCallbacks;
|
|
|
@property (strong, nonatomic) NSMutableDictionary *HTTPHeaders;
|
|
|
// This queue is used to serialize the handling of the network responses of all the download operation in a single queue
|
...
|
...
|
@@ -63,6 +64,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; |
|
|
|
|
|
- (id)init {
|
|
|
if ((self = [super init])) {
|
|
|
_operationClass = [SDWebImageDownloaderOperation class];
|
|
|
_executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
|
|
|
_downloadQueue = [NSOperationQueue new];
|
|
|
_downloadQueue.maxConcurrentOperationCount = 2;
|
...
|
...
|
@@ -104,6 +106,10 @@ static NSString *const kCompletedCallbackKey = @"completed"; |
|
|
return _downloadQueue.maxConcurrentOperationCount;
|
|
|
}
|
|
|
|
|
|
- (void)setOperationClass:(Class)operationClass {
|
|
|
_operationClass = operationClass ?: [SDWebImageDownloaderOperation class];
|
|
|
}
|
|
|
|
|
|
- (id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock {
|
|
|
__block SDWebImageDownloaderOperation *operation;
|
|
|
__weak SDWebImageDownloader *wself = self;
|
...
|
...
|
@@ -124,7 +130,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; |
|
|
else {
|
|
|
request.allHTTPHeaderFields = wself.HTTPHeaders;
|
|
|
}
|
|
|
operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request
|
|
|
operation = [[wself.operationClass alloc] initWithRequest:request
|
|
|
options:options
|
|
|
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
|
|
|
SDWebImageDownloader *sself = wself;
|
...
|
...
|
|