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
|
||||
*/
|
||||
- (void)updateProgress:(double)progress;
|
||||
- (void)updateIndicatorProgress:(double)progress;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -174,7 +174,11 @@
|
|||
- (void)startAnimatingIndicator {
|
||||
self.indicatorView.hidden = NO;
|
||||
#if SD_UIKIT
|
||||
if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) {
|
||||
// Ignore NSProgress
|
||||
} else {
|
||||
self.indicatorView.progress = 0;
|
||||
}
|
||||
#else
|
||||
self.indicatorView.indeterminate = YES;
|
||||
self.indicatorView.doubleValue = 0;
|
||||
|
@ -185,7 +189,11 @@
|
|||
- (void)stopAnimatingIndicator {
|
||||
self.indicatorView.hidden = YES;
|
||||
#if SD_UIKIT
|
||||
if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) {
|
||||
// Ignore NSProgress
|
||||
} else {
|
||||
self.indicatorView.progress = 1;
|
||||
}
|
||||
#else
|
||||
self.indicatorView.indeterminate = NO;
|
||||
self.indicatorView.doubleValue = 1;
|
||||
|
@ -193,9 +201,13 @@
|
|||
#endif
|
||||
}
|
||||
|
||||
- (void)updateProgress:(double)progress {
|
||||
- (void)updateIndicatorProgress:(double)progress {
|
||||
#if SD_UIKIT
|
||||
if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) {
|
||||
// Ignore NSProgress
|
||||
} else {
|
||||
[self.indicatorView setProgress:progress animated:YES];
|
||||
}
|
||||
#else
|
||||
self.indicatorView.indeterminate = progress > 0 ? NO : YES;
|
||||
self.indicatorView.doubleValue = progress * 100;
|
||||
|
|
|
@ -73,13 +73,13 @@ static char imageURLKey;
|
|||
}
|
||||
|
||||
if (url) {
|
||||
// check and start image indicator
|
||||
[self sd_startImageIndicator];
|
||||
|
||||
// reset the progress
|
||||
self.sd_imageProgress.totalUnitCount = 0;
|
||||
self.sd_imageProgress.completedUnitCount = 0;
|
||||
|
||||
// check and start image indicator
|
||||
[self sd_startImageIndicator];
|
||||
|
||||
SDWebImageManager *manager;
|
||||
if ([context valueForKey:SDWebImageContextCustomManager]) {
|
||||
manager = (SDWebImageManager *)[context valueForKey:SDWebImageContextCustomManager];
|
||||
|
@ -99,22 +99,24 @@ static char imageURLKey;
|
|||
if ([imageIndicator conformsToProtocol:@protocol(SDWebImageProgressIndicator)]) {
|
||||
double progress = wself.sd_imageProgress.fractionCompleted;
|
||||
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) {
|
||||
__strong __typeof (wself) sself = wself;
|
||||
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 (finished && !error && sself.sd_imageProgress.totalUnitCount == 0 && sself.sd_imageProgress.completedUnitCount == 0) {
|
||||
sself.sd_imageProgress.totalUnitCount = SDWebImageProgressUnitCountUnknown;
|
||||
sself.sd_imageProgress.completedUnitCount = SDWebImageProgressUnitCountUnknown;
|
||||
}
|
||||
|
||||
// check and stop image indicator
|
||||
if (finished) {
|
||||
[self sd_stopImageIndicator];
|
||||
}
|
||||
|
||||
BOOL shouldCallCompletedBlock = finished || (options & SDWebImageAvoidAutoSetImage);
|
||||
BOOL shouldNotSetImage = ((image && (options & SDWebImageAvoidAutoSetImage)) ||
|
||||
(!image && !(options & SDWebImageDelayPlaceholder)));
|
||||
|
|
Loading…
Reference in New Issue