Browse Source

more clean up

gwangbeom 7 years ago
parent
commit
80051a937d

+ 1 - 1
Demo/Demo/Kingfisher-watchOS-Demo Extension/InterfaceController.swift

@@ -47,7 +47,7 @@ class InterfaceController: WKInterfaceController {
     
     func refreshImage() {
         let url = URL(string: "https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/kingfisher-\(currentIndex! + 1).jpg")!
-        self.interfaceImage.kf.setImage(url)
+        interfaceImage.kf.setImage(url)
     }
 
     override func willActivate() {

+ 2 - 2
Sources/Cache/ImageCache.swift

@@ -305,7 +305,7 @@ open class ImageCache {
             }
         } else {
             var sSelf: ImageCache! = self
-            block = DispatchWorkItem(block: {
+            block = DispatchWorkItem {
                 // Begin to load image from disk
                 if let image = sSelf.retrieveImageInDiskCache(forKey: key, options: options) {
                     if options.backgroundDecode {
@@ -344,7 +344,7 @@ open class ImageCache {
                         sSelf = nil
                     }
                 }
-            })
+            }
             
             sSelf.ioQueue.async(execute: block!)
         }

+ 1 - 1
Sources/Extensions/ImageView+Kingfisher.swift

@@ -94,7 +94,7 @@ extension KingfisherClass where Base: ImageView {
                     progressBlock(receivedSize, totalSize)
                 }
             },
-            completionHandler: {[weak base] image, error, cacheType, imageURL in
+            completionHandler: { [weak base] image, error, cacheType, imageURL in
                 DispatchQueue.main.safeAsync {
                     maybeIndicator?.stopAnimatingView()
                     guard let strongBase = base, imageURL == self.webURL else {

+ 2 - 2
Sources/Extensions/NSButton+Kingfisher.swift

@@ -80,7 +80,7 @@ extension KingfisherClass where Base: NSButton {
                     progressBlock(receivedSize, totalSize)
                 }
             },
-            completionHandler: {[weak base] image, error, cacheType, imageURL in
+            completionHandler: { [weak base] image, error, cacheType, imageURL in
                 DispatchQueue.main.safeAsync {
                     guard let strongBase = base, imageURL == self.webURL else {
                         completionHandler?(image, error, cacheType, imageURL)
@@ -155,7 +155,7 @@ extension KingfisherClass where Base: NSButton {
                     progressBlock(receivedSize, totalSize)
                 }
             },
-            completionHandler: {[weak base] image, error, cacheType, imageURL in
+            completionHandler: { [weak base] image, error, cacheType, imageURL in
                 DispatchQueue.main.safeAsync {
                     guard let strongBase = base, imageURL == self.alternateWebURL else {
                         completionHandler?(image, error, cacheType, imageURL)

+ 1 - 1
Sources/Extensions/UIButton+Kingfisher.swift

@@ -82,7 +82,7 @@ extension KingfisherClass where Base: UIButton {
                     progressBlock(receivedSize, totalSize)
                 }
             },
-            completionHandler: {[weak base] image, error, cacheType, imageURL in
+            completionHandler: { [weak base] image, error, cacheType, imageURL in
                 DispatchQueue.main.safeAsync {
                     guard let strongBase = base, imageURL == self.webURL(for: state) else {
                         completionHandler?(image, error, cacheType, imageURL)

+ 4 - 6
Sources/General/KingfisherManager.swift

@@ -175,13 +175,12 @@ public class KingfisherManager {
                                       forKey: key,
                                       processorIdentifier:options.processor.identifier,
                                       cacheSerializer: options.cacheSerializer,
-                                      toDisk: !options.cacheMemoryOnly,
-                                      completionHandler: {
+                                      toDisk: !options.cacheMemoryOnly) {
                                         guard options.waitForCache else { return }
                                         
                                         let cacheType = targetCache.imageCachedType(forKey: key, processorIdentifier: options.processor.identifier)
                                         completionHandler?(image, nil, cacheType, url)
-                    })
+                    }
                     
                     if options.cacheOriginalImage && options.processor != DefaultImageProcessor.default {
                         let originalCache = options.originalCache ?? targetCache
@@ -275,15 +274,14 @@ public class KingfisherManager {
                                       forKey: key,
                                       processorIdentifier:options.processor.identifier,
                                       cacheSerializer: options.cacheSerializer,
-                                      toDisk: !options.cacheMemoryOnly,
-                                      completionHandler: {
+                                      toDisk: !options.cacheMemoryOnly) {
                                         guard options.waitForCache else { return }
 
                                         let cacheType = targetCache.imageCachedType(forKey: key, processorIdentifier: options.processor.identifier)
                                         options.callbackDispatchQueue.safeAsync {
                                             diskTaskCompletionHandler(processedImage, nil, cacheType, url)
                                         }
-                    })
+                    }
 
                     if options.waitForCache == false {
                         options.callbackDispatchQueue.safeAsync {

+ 2 - 2
Tests/KingfisherTests/ImageModifierTests.swift

@@ -40,9 +40,9 @@ class ImageModifierTests: XCTestCase {
     }
 
     func testAnyImageModifier() {
-        let m = AnyImageModifier(modify: { image in
+        let m = AnyImageModifier { image in
             return image
-        })
+        }
         let image = Image(data: testImagePNGData)!
         let modifiedImage = m.modify(image)
         XCTAssert(modifiedImage == image)