Remove SDWebImageProgressIndicator protocol. Add this as an optional method in SDWebImageIndicator

This commit is contained in:
DreamPiggy 2018-02-04 15:19:40 +08:00
parent d28870cd52
commit 89babbbfbe
2 changed files with 6 additions and 12 deletions

View File

@ -30,15 +30,9 @@
*/
- (void)stopAnimatingIndicator;
@end
// A protocol to custom the indicator which need update when loading progress changed
// All of these methods are called from main queue
@protocol SDWebImageProgressIndicator <SDWebImageIndicator>
@required
@optional
/**
Update the progress (0-1.0) for progress indicator.
Update the loading progress (0-1.0) for indicator. Optional
@param progress The progress, value between 0 and 1.0
*/
@ -80,7 +74,7 @@
// Progress indicator class
// for UIKit(macOS), it use a `UIProgressView`
// for AppKit(macOS), it use a `NSProgressIndicator` with the bar style
@interface SDWebImageProgressIndicator : NSObject <SDWebImageProgressIndicator>
@interface SDWebImageProgressIndicator : NSObject <SDWebImageIndicator>
#if SD_UIKIT
@property (nonatomic, strong, readonly, nonnull) UIProgressView *indicatorView;

View File

@ -96,10 +96,10 @@ static char imageURLKey;
if (progressBlock) {
progressBlock(receivedSize, expectedSize, targetURL);
}
if ([imageIndicator conformsToProtocol:@protocol(SDWebImageProgressIndicator)]) {
if ([imageIndicator respondsToSelector:@selector(updateIndicatorProgress:)]) {
double progress = wself.sd_imageProgress.fractionCompleted;
dispatch_async(dispatch_get_main_queue(), ^{
[((id<SDWebImageProgressIndicator>)imageIndicator) updateIndicatorProgress:progress];
[imageIndicator updateIndicatorProgress:progress];
});
}
};