Rename to updateIndicatorProgress. Change the order for progress update and indicator to allow `observedProgress` works.
This commit is contained in:
parent
1ebac224db
commit
529f6fe4bf
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
@param progress The progress, value between 0 and 1.0
|
@param progress The progress, value between 0 and 1.0
|
||||||
*/
|
*/
|
||||||
- (void)updateProgress:(double)progress;
|
- (void)updateIndicatorProgress:(double)progress;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,11 @@
|
||||||
- (void)startAnimatingIndicator {
|
- (void)startAnimatingIndicator {
|
||||||
self.indicatorView.hidden = NO;
|
self.indicatorView.hidden = NO;
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
self.indicatorView.progress = 0;
|
if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) {
|
||||||
|
// Ignore NSProgress
|
||||||
|
} else {
|
||||||
|
self.indicatorView.progress = 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
self.indicatorView.indeterminate = YES;
|
self.indicatorView.indeterminate = YES;
|
||||||
self.indicatorView.doubleValue = 0;
|
self.indicatorView.doubleValue = 0;
|
||||||
|
@ -185,7 +189,11 @@
|
||||||
- (void)stopAnimatingIndicator {
|
- (void)stopAnimatingIndicator {
|
||||||
self.indicatorView.hidden = YES;
|
self.indicatorView.hidden = YES;
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
self.indicatorView.progress = 1;
|
if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) {
|
||||||
|
// Ignore NSProgress
|
||||||
|
} else {
|
||||||
|
self.indicatorView.progress = 1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
self.indicatorView.indeterminate = NO;
|
self.indicatorView.indeterminate = NO;
|
||||||
self.indicatorView.doubleValue = 1;
|
self.indicatorView.doubleValue = 1;
|
||||||
|
@ -193,9 +201,13 @@
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateProgress:(double)progress {
|
- (void)updateIndicatorProgress:(double)progress {
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
[self.indicatorView setProgress:progress animated:YES];
|
if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) {
|
||||||
|
// Ignore NSProgress
|
||||||
|
} else {
|
||||||
|
[self.indicatorView setProgress:progress animated:YES];
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
self.indicatorView.indeterminate = progress > 0 ? NO : YES;
|
self.indicatorView.indeterminate = progress > 0 ? NO : YES;
|
||||||
self.indicatorView.doubleValue = progress * 100;
|
self.indicatorView.doubleValue = progress * 100;
|
||||||
|
|
|
@ -73,13 +73,13 @@ static char imageURLKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
// check and start image indicator
|
|
||||||
[self sd_startImageIndicator];
|
|
||||||
|
|
||||||
// reset the progress
|
// reset the progress
|
||||||
self.sd_imageProgress.totalUnitCount = 0;
|
self.sd_imageProgress.totalUnitCount = 0;
|
||||||
self.sd_imageProgress.completedUnitCount = 0;
|
self.sd_imageProgress.completedUnitCount = 0;
|
||||||
|
|
||||||
|
// check and start image indicator
|
||||||
|
[self sd_startImageIndicator];
|
||||||
|
|
||||||
SDWebImageManager *manager;
|
SDWebImageManager *manager;
|
||||||
if ([context valueForKey:SDWebImageContextCustomManager]) {
|
if ([context valueForKey:SDWebImageContextCustomManager]) {
|
||||||
manager = (SDWebImageManager *)[context valueForKey:SDWebImageContextCustomManager];
|
manager = (SDWebImageManager *)[context valueForKey:SDWebImageContextCustomManager];
|
||||||
|
@ -99,22 +99,24 @@ static char imageURLKey;
|
||||||
if ([imageIndicator conformsToProtocol:@protocol(SDWebImageProgressIndicator)]) {
|
if ([imageIndicator conformsToProtocol:@protocol(SDWebImageProgressIndicator)]) {
|
||||||
double progress = wself.sd_imageProgress.fractionCompleted;
|
double progress = wself.sd_imageProgress.fractionCompleted;
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[((id<SDWebImageProgressIndicator>)imageIndicator) updateProgress:progress];
|
[((id<SDWebImageProgressIndicator>)imageIndicator) updateIndicatorProgress:progress];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
id <SDWebImageOperation> operation = [manager loadImageWithURL:url options:options progress:combinedProgressBlock completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
id <SDWebImageOperation> operation = [manager loadImageWithURL:url options:options progress:combinedProgressBlock completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||||
__strong __typeof (wself) sself = wself;
|
__strong __typeof (wself) sself = wself;
|
||||||
if (!sself) { return; }
|
if (!sself) { return; }
|
||||||
// check and stop image indicator
|
|
||||||
if (finished) {
|
|
||||||
[self sd_stopImageIndicator];
|
|
||||||
}
|
|
||||||
// if the progress not been updated, mark it to complete state
|
// if the progress not been updated, mark it to complete state
|
||||||
if (finished && !error && sself.sd_imageProgress.totalUnitCount == 0 && sself.sd_imageProgress.completedUnitCount == 0) {
|
if (finished && !error && sself.sd_imageProgress.totalUnitCount == 0 && sself.sd_imageProgress.completedUnitCount == 0) {
|
||||||
sself.sd_imageProgress.totalUnitCount = SDWebImageProgressUnitCountUnknown;
|
sself.sd_imageProgress.totalUnitCount = SDWebImageProgressUnitCountUnknown;
|
||||||
sself.sd_imageProgress.completedUnitCount = SDWebImageProgressUnitCountUnknown;
|
sself.sd_imageProgress.completedUnitCount = SDWebImageProgressUnitCountUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check and stop image indicator
|
||||||
|
if (finished) {
|
||||||
|
[self sd_stopImageIndicator];
|
||||||
|
}
|
||||||
|
|
||||||
BOOL shouldCallCompletedBlock = finished || (options & SDWebImageAvoidAutoSetImage);
|
BOOL shouldCallCompletedBlock = finished || (options & SDWebImageAvoidAutoSetImage);
|
||||||
BOOL shouldNotSetImage = ((image && (options & SDWebImageAvoidAutoSetImage)) ||
|
BOOL shouldNotSetImage = ((image && (options & SDWebImageAvoidAutoSetImage)) ||
|
||||||
(!image && !(options & SDWebImageDelayPlaceholder)));
|
(!image && !(options & SDWebImageDelayPlaceholder)));
|
||||||
|
|
Loading…
Reference in New Issue