From 89babbbfbe09fda697b566624c31162380dfe884 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 4 Feb 2018 15:19:40 +0800 Subject: [PATCH] Remove SDWebImageProgressIndicator protocol. Add this as an optional method in SDWebImageIndicator --- SDWebImage/SDWebImageIndicator.h | 14 ++++---------- SDWebImage/UIView+WebCache.m | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/SDWebImage/SDWebImageIndicator.h b/SDWebImage/SDWebImageIndicator.h index df1cf969..f6ab96f6 100644 --- a/SDWebImage/SDWebImageIndicator.h +++ b/SDWebImage/SDWebImageIndicator.h @@ -30,16 +30,10 @@ */ - (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 - -@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 */ - (void)updateIndicatorProgress:(double)progress; @@ -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 +@interface SDWebImageProgressIndicator : NSObject #if SD_UIKIT @property (nonatomic, strong, readonly, nonnull) UIProgressView *indicatorView; diff --git a/SDWebImage/UIView+WebCache.m b/SDWebImage/UIView+WebCache.m index f929d7ff..3ab40e82 100644 --- a/SDWebImage/UIView+WebCache.m +++ b/SDWebImage/UIView+WebCache.m @@ -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)imageIndicator) updateIndicatorProgress:progress]; + [imageIndicator updateIndicatorProgress:progress]; }); } };