Skip to content

Commit 8382899

Browse files
committed
Merge pull request SDWebImage#984 from gztchan:master
Add url as param to progress block
2 parents e844a85 + cee50eb commit 8382899

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Examples/SDWebImage Demo/DetailViewController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ - (void)configureView
4242
[self.imageView sd_setImageWithURL:self.imageURL
4343
placeholderImage:nil
4444
options:SDWebImageProgressiveDownload
45-
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
45+
progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL *targetURL) {
4646
if (!activityIndicator) {
4747
[weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
4848
activityIndicator.center = weakImageView.center;

SDWebImage/SDWebImageDownloader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
6666
extern NSString * _Nonnull const SDWebImageDownloadStartNotification;
6767
extern NSString * _Nonnull const SDWebImageDownloadStopNotification;
6868

69-
typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
69+
typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL);
7070

7171
typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished);
7272

SDWebImage/SDWebImageDownloaderOperation.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ - (void)start {
169169

170170
if (self.dataTask) {
171171
for (SDWebImageDownloaderProgressBlock progressBlock in [self callbacksForKey:kProgressCallbackKey]) {
172-
progressBlock(0, NSURLResponseUnknownLength);
172+
progressBlock(0, NSURLResponseUnknownLength, self.request.URL);
173173
}
174174
dispatch_async(dispatch_get_main_queue(), ^{
175175
[[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self];
@@ -262,7 +262,7 @@ - (void)URLSession:(NSURLSession *)session
262262
NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0;
263263
self.expectedSize = expected;
264264
for (SDWebImageDownloaderProgressBlock progressBlock in [self callbacksForKey:kProgressCallbackKey]) {
265-
progressBlock(0, expected);
265+
progressBlock(0, expected, self.request.URL);
266266
}
267267

268268
self.imageData = [[NSMutableData alloc] initWithCapacity:expected];
@@ -378,7 +378,7 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)data
378378
}
379379

380380
for (SDWebImageDownloaderProgressBlock progressBlock in [self callbacksForKey:kProgressCallbackKey]) {
381-
progressBlock(self.imageData.length, self.expectedSize);
381+
progressBlock(self.imageData.length, self.expectedSize, self.request.URL);
382382
}
383383
}
384384

0 commit comments

Comments
 (0)