Просмотр исходного кода

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

DreamPiggy 8 лет назад
Родитель
Сommit
89babbbfbe
2 измененных файлов с 6 добавлено и 12 удалено
  1. 4 10
      SDWebImage/SDWebImageIndicator.h
  2. 2 2
      SDWebImage/UIView+WebCache.m

+ 4 - 10
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 <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
  */
 - (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 <SDWebImageProgressIndicator>
+@interface SDWebImageProgressIndicator : NSObject <SDWebImageIndicator>
 
 #if SD_UIKIT
 @property (nonatomic, strong, readonly, nonnull) UIProgressView *indicatorView;

+ 2 - 2
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<SDWebImageProgressIndicator>)imageIndicator) updateIndicatorProgress:progress];
+                    [imageIndicator updateIndicatorProgress:progress];
                 });
             }
         };