Merge branch 'master' of https://github.com/SDWebImage/SDWebImage into gif
This commit is contained in:
commit
f65ab801d0
|
@ -346,18 +346,12 @@
|
|||
SDWebImageDownloaderConfig *config = SDWebImageDownloaderConfig.defaultDownloaderConfig;
|
||||
config.minimumProgressInterval = 0.51; // This will make the progress only callback twice (once is 51%, another is 100%)
|
||||
SDWebImageDownloader *downloader = [[SDWebImageDownloader alloc] initWithConfig:config];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://www.ioncannon.net/wp-content/uploads/2011/06/test2.webp"];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_1.jpg"];
|
||||
__block NSUInteger allProgressCount = 0; // All progress (including operation start / first HTTP response, etc)
|
||||
__block NSUInteger validProgressCount = 0; // Only progress from `URLSession:dataTask:didReceiveData:`
|
||||
[downloader downloadImageWithURL:imageURL options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
|
||||
allProgressCount++;
|
||||
if (expectedSize <= 0 || receivedSize <= 0) {
|
||||
// ignore the progress callback until we receive data
|
||||
return;
|
||||
}
|
||||
validProgressCount++;
|
||||
} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
if (allProgressCount > 2 && validProgressCount == 2) {
|
||||
if (allProgressCount > 0) {
|
||||
[expectation fulfill];
|
||||
} else {
|
||||
XCTFail(@"Progress callback more than once");
|
||||
|
|
Loading…
Reference in New Issue