gwangbeom 7 лет назад
Родитель
Сommit
526afdcd33

+ 4 - 4
Sources/Cache/ImageCache.swift

@@ -40,7 +40,7 @@ extension Notification.Name {
      
      The main purpose of this notification is supplying a chance to maintain some necessary information on the cached files. See [this wiki](https://github.com/onevcat/Kingfisher/wiki/How-to-implement-ETag-based-304-(Not-Modified)-handling-in-Kingfisher) for a use case on it.
      */
-    public static let KingfisherDidCleanDiskCache = Notification.Name.init("com.onevcat.Kingfisher.KingfisherDidCleanDiskCache")
+    public static let KingfisherDidCleanDiskCache = Notification.Name("com.onevcat.Kingfisher.KingfisherDidCleanDiskCache")
 }
 
 /**
@@ -84,7 +84,7 @@ open class ImageCache {
     /// memory warning notification is received.
     open var maxMemoryCost: UInt = 0 {
         didSet {
-            self.memoryCache.totalCostLimit = Int(maxMemoryCost)
+            memoryCache.totalCostLimit = Int(maxMemoryCost)
         }
     }
     
@@ -295,7 +295,7 @@ open class ImageCache {
         let options = options ?? KingfisherEmptyOptionsInfo
         let imageModifier = options.imageModifier
 
-        if let image = self.retrieveImageInMemoryCache(forKey: key, options: options) {
+        if let image = retrieveImageInMemoryCache(forKey: key, options: options) {
             options.callbackDispatchQueue.safeAsync {
                 completionHandler(imageModifier.modify(image), .memory)
             }
@@ -650,7 +650,7 @@ extension ImageCache {
     }
     
     func cacheFileName(forComputedKey key: String) -> String {
-        if let ext = self.pathExtension {
+        if let ext = pathExtension {
           return (key.kf.md5 as NSString).appendingPathExtension(ext)!
         }
         return key.kf.md5

+ 2 - 2
Sources/General/KingfisherManager.swift

@@ -123,7 +123,7 @@ public class KingfisherManager {
         let task = RetrieveImageTask()
         let options = currentDefaultOptions + (options ?? KingfisherEmptyOptionsInfo)
         if options.forceRefresh {
-            _ = downloadAndCacheImage(
+            downloadAndCacheImage(
                 with: resource.downloadURL,
                 forKey: resource.cacheKey,
                 retrieveImageTask: task,
@@ -224,7 +224,7 @@ public class KingfisherManager {
                 diskTaskCompletionHandler(nil, error, .none, url)
                 return
             }
-            self.downloadAndCacheImage(
+            downloadAndCacheImage(
                 with: url,
                 forKey: key,
                 retrieveImageTask: retrieveImageTask,

+ 11 - 11
Sources/General/KingfisherOptionsInfo.swift

@@ -169,11 +169,11 @@ infix operator <== : ItemComparisonPrecedence
 // This operator returns true if two `KingfisherOptionsInfoItem` enum is the same, without considering the associated values.
 func <== (lhs: KingfisherOptionsInfoItem, rhs: KingfisherOptionsInfoItem) -> Bool {
     switch (lhs, rhs) {
-    case (.targetCache(_), .targetCache(_)): return true
-    case (.originalCache(_), .originalCache(_)): return true
-    case (.downloader(_), .downloader(_)): return true
-    case (.transition(_), .transition(_)): return true
-    case (.downloadPriority(_), .downloadPriority(_)): return true
+    case (.targetCache, .targetCache): return true
+    case (.originalCache, .originalCache): return true
+    case (.downloader, .downloader): return true
+    case (.transition, .transition): return true
+    case (.downloadPriority, .downloadPriority): return true
     case (.forceRefresh, .forceRefresh): return true
     case (.fromMemoryCacheOrRefresh, .fromMemoryCacheOrRefresh): return true
     case (.forceTransition, .forceTransition): return true
@@ -181,13 +181,13 @@ func <== (lhs: KingfisherOptionsInfoItem, rhs: KingfisherOptionsInfoItem) -> Boo
     case (.waitForCache, .waitForCache): return true
     case (.onlyFromCache, .onlyFromCache): return true
     case (.backgroundDecode, .backgroundDecode): return true
-    case (.callbackDispatchQueue(_), .callbackDispatchQueue(_)): return true
-    case (.scaleFactor(_), .scaleFactor(_)): return true
+    case (.callbackDispatchQueue, .callbackDispatchQueue): return true
+    case (.scaleFactor, .scaleFactor): return true
     case (.preloadAllAnimationData, .preloadAllAnimationData): return true
-    case (.requestModifier(_), .requestModifier(_)): return true
-    case (.processor(_), .processor(_)): return true
-    case (.cacheSerializer(_), .cacheSerializer(_)): return true
-    case (.imageModifier(_), .imageModifier(_)): return true
+    case (.requestModifier, .requestModifier): return true
+    case (.processor, .processor): return true
+    case (.cacheSerializer, .cacheSerializer): return true
+    case (.imageModifier, .imageModifier): return true
     case (.keepCurrentImageWhileLoading, .keepCurrentImageWhileLoading): return true
     case (.onlyLoadFirstFrame, .onlyLoadFirstFrame): return true
     case (.cacheOriginalImage, .cacheOriginalImage): return true

+ 1 - 1
Sources/Image/Filter.swift

@@ -45,7 +45,7 @@ extension CIImageProcessor {
         switch item {
         case .image(let image):
             return image.kf.apply(filter)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }

+ 9 - 9
Sources/Image/ImageProcessor.swift

@@ -207,7 +207,7 @@ public struct BlendImageProcessor: ImageProcessor {
         case .image(let image):
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.image(withBlendMode: blendMode, alpha: alpha, backgroundColor: backgroundColor)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -265,7 +265,7 @@ public struct CompositingImageProcessor: ImageProcessor {
         case .image(let image):
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.image(withCompositingOperation: compositingOperation, alpha: alpha, backgroundColor: backgroundColor)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -336,7 +336,7 @@ public struct RoundCornerImageProcessor: ImageProcessor {
             let size = targetSize ?? image.kf.size
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.image(withRoundRadius: cornerRadius, fit: size, roundingCorners: roundingCorners, backgroundColor: backgroundColor)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -411,7 +411,7 @@ public struct ResizingImageProcessor: ImageProcessor {
         case .image(let image):
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.resize(to: referenceSize, for: targetContentMode)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -450,7 +450,7 @@ public struct BlurImageProcessor: ImageProcessor {
             let radius = blurRadius * options.scaleFactor
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.blurred(withRadius: radius)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -493,7 +493,7 @@ public struct OverlayImageProcessor: ImageProcessor {
         case .image(let image):
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.overlaying(with: overlay, fraction: fraction)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -530,7 +530,7 @@ public struct TintImageProcessor: ImageProcessor {
         case .image(let image):
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.tinted(with: tint)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -583,7 +583,7 @@ public struct ColorControlsProcessor: ImageProcessor {
         case .image(let image):
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.adjusted(brightness: brightness, contrast: contrast, saturation: saturation, inputEV: inputEV)
-        case .data(_):
+        case .data:
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
@@ -669,7 +669,7 @@ public struct CroppingImageProcessor: ImageProcessor {
         case .image(let image):
             return image.kf.scaled(to: options.scaleFactor)
                         .kf.crop(to: size, anchorOn: anchor)
-        case .data(_): return (DefaultImageProcessor.default >> self).process(item: item, options: options)
+        case .data: return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }
     }
 }

+ 5 - 5
Sources/Image/ImageTransition.swift

@@ -100,12 +100,12 @@ public enum ImageTransition {
     var animationOptions: UIView.AnimationOptions {
         switch self {
         case .none:                         return []
-        case .fade(_):                      return .transitionCrossDissolve
+        case .fade:                         return .transitionCrossDissolve
             
-        case .flipFromLeft(_):              return .transitionFlipFromLeft
-        case .flipFromRight(_):             return .transitionFlipFromRight
-        case .flipFromTop(_):               return .transitionFlipFromTop
-        case .flipFromBottom(_):            return .transitionFlipFromBottom
+        case .flipFromLeft:                 return .transitionFlipFromLeft
+        case .flipFromRight:                return .transitionFlipFromRight
+        case .flipFromTop:                  return .transitionFlipFromTop
+        case .flipFromBottom:               return .transitionFlipFromBottom
             
         case .custom(_, let options, _, _): return options
         }

+ 2 - 2
Sources/Image/Placeholder.swift

@@ -66,7 +66,7 @@ extension Placeholder where Self: View {
     public func add(to imageView: ImageView) {
         imageView.addSubview(self)
 
-        self.translatesAutoresizingMaskIntoConstraints = false
+        translatesAutoresizingMaskIntoConstraints = false
         NSLayoutConstraint.activate([
             NSLayoutConstraint(item: self, attribute: .centerX, relatedBy: .equal, toItem: imageView, attribute: .centerX, multiplier: 1, constant: 0),
             NSLayoutConstraint(item: self, attribute: .centerY, relatedBy: .equal, toItem: imageView, attribute: .centerY, multiplier: 1, constant: 0),
@@ -77,6 +77,6 @@ extension Placeholder where Self: View {
 
     /// How the placeholder should be removed from a given image view.
     public func remove(from imageView: ImageView) {
-        self.removeFromSuperview()
+        removeFromSuperview()
     }
 }

+ 2 - 2
Sources/Networking/ImageDownloader.swift

@@ -334,7 +334,7 @@ open class ImageDownloader {
             return nil
         }
         
-        let timeout = self.downloadTimeout == 0.0 ? 15.0 : self.downloadTimeout
+        let timeout = downloadTimeout == 0.0 ? 15.0 : downloadTimeout
         
         // We need to set the URL as the load key. So before setup progress, we need to ask the `requestModifier` for a final URL.
         var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: timeout)
@@ -418,7 +418,7 @@ extension ImageDownloader {
         
         func getFetchLoad(from task: RetrieveImageDownloadTask) -> ImageFetchLoad? {
             guard let URL = task.internalTask.originalRequest?.url,
-                  let imageFetchLoad = self.fetchLoads[URL] else
+                  let imageFetchLoad = fetchLoads[URL] else
             {
                 return nil
             }

+ 4 - 4
Sources/Networking/ImagePrefetcher.swift

@@ -75,7 +75,7 @@ public class ImagePrefetcher {
     private let manager: KingfisherManager
     
     private var finished: Bool {
-        return failedResources.count + skippedResources.count + completedResources.count == prefetchResources.count && self.tasks.isEmpty
+        return failedResources.count + skippedResources.count + completedResources.count == prefetchResources.count && tasks.isEmpty
     }
     
     /**
@@ -137,10 +137,10 @@ public class ImagePrefetcher {
         // Add our own callback dispatch queue to make sure all callbacks are coming back in our expected queue
         optionsInfoWithoutQueue.append(.callbackDispatchQueue(prefetchQueue))
         
-        self.optionsInfo = optionsInfoWithoutQueue
+        optionsInfo = optionsInfoWithoutQueue
         
-        let cache = self.optionsInfo.targetCache ?? .default
-        let downloader = self.optionsInfo.downloader ?? .default
+        let cache = optionsInfo.targetCache ?? .default
+        let downloader = optionsInfo.downloader ?? .default
         manager = KingfisherManager(downloader: downloader, cache: cache)
         
         self.progressBlock = progressBlock

+ 2 - 2
Sources/Views/Indicator.swift

@@ -144,8 +144,8 @@ final class ImageIndicator: Indicator {
         
         #if os(macOS)
             // Need for gif to animate on macOS
-            self.animatedImageIndicatorView.imageScaling = .scaleNone
-            self.animatedImageIndicatorView.canDrawSubviewsIntoLayer = true
+            animatedImageIndicatorView.imageScaling = .scaleNone
+            animatedImageIndicatorView.canDrawSubviewsIntoLayer = true
         #else
             animatedImageIndicatorView.contentMode = .center
         #endif