Bladeren bron

Revert "Flag that image was downloaded"

This reverts commit d06a35747611db67000b2edb154977c81ffec1ed.
Igor Nikitin 9 jaren geleden
bovenliggende
commit
b727a330db

+ 1 - 1
Sources/ImagePrefetcher.swift

@@ -199,7 +199,7 @@ public class ImagePrefetcher {
             retrieveImageTask: task,
             retrieveImageTask: task,
             progressBlock: nil,
             progressBlock: nil,
             completionHandler: {
             completionHandler: {
-                (image, error, _, _, _) -> () in
+                (image, error, _, _) -> () in
                 
                 
                 self.tasks.removeValue(forKey: resource.downloadURL)
                 self.tasks.removeValue(forKey: resource.downloadURL)
                 
                 

+ 1 - 1
Sources/ImageView+Kingfisher.swift

@@ -120,7 +120,7 @@ extension ImageView {
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
                 }
                 }
             },
             },
-            completionHandler: {[weak self] image, error, cacheType, _, imageURL in
+            completionHandler: {[weak self] image, error, cacheType, imageURL in
                 
                 
                 dispatch_async_safely_to_main_queue {
                 dispatch_async_safely_to_main_queue {
                     guard let sSelf = self, imageURL == sSelf.kf_webURL else {
                     guard let sSelf = self, imageURL == sSelf.kf_webURL else {

+ 9 - 11
Sources/KingfisherManager.swift

@@ -32,7 +32,6 @@ import UIKit
 
 
 public typealias DownloadProgressBlock = ((receivedSize: Int64, totalSize: Int64) -> ())
 public typealias DownloadProgressBlock = ((receivedSize: Int64, totalSize: Int64) -> ())
 public typealias CompletionHandler = ((image: Image?, error: NSError?, cacheType: CacheType, imageURL: URL?) -> ())
 public typealias CompletionHandler = ((image: Image?, error: NSError?, cacheType: CacheType, imageURL: URL?) -> ())
-public typealias RetrieveCompletionHandler = ((image: Image?, error: NSError?, cacheType: CacheType, wasDownloaded: Bool, imageURL: URL?) -> ())
 
 
 /// RetrieveImageTask represents a task of image retrieving process.
 /// RetrieveImageTask represents a task of image retrieving process.
 /// It contains an async task of getting image from disk and from network.
 /// It contains an async task of getting image from disk and from network.
@@ -120,7 +119,7 @@ public class KingfisherManager {
     public func retrieveImageWithResource(_ resource: Resource,
     public func retrieveImageWithResource(_ resource: Resource,
         optionsInfo: KingfisherOptionsInfo?,
         optionsInfo: KingfisherOptionsInfo?,
         progressBlock: DownloadProgressBlock?,
         progressBlock: DownloadProgressBlock?,
-        completionHandler: RetrieveCompletionHandler?) -> RetrieveImageTask
+        completionHandler: CompletionHandler?) -> RetrieveImageTask
     {
     {
         let task = RetrieveImageTask()
         let task = RetrieveImageTask()
 
 
@@ -163,7 +162,7 @@ public class KingfisherManager {
     public func retrieveImageWithURL(_ URL: Foundation.URL,
     public func retrieveImageWithURL(_ URL: Foundation.URL,
                              optionsInfo: KingfisherOptionsInfo?,
                              optionsInfo: KingfisherOptionsInfo?,
                            progressBlock: DownloadProgressBlock?,
                            progressBlock: DownloadProgressBlock?,
-                       completionHandler: RetrieveCompletionHandler?) -> RetrieveImageTask
+                       completionHandler: CompletionHandler?) -> RetrieveImageTask
     {
     {
         return retrieveImageWithResource(Resource(downloadURL: URL), optionsInfo: optionsInfo, progressBlock: progressBlock, completionHandler: completionHandler)
         return retrieveImageWithResource(Resource(downloadURL: URL), optionsInfo: optionsInfo, progressBlock: progressBlock, completionHandler: completionHandler)
     }
     }
@@ -173,7 +172,7 @@ public class KingfisherManager {
                                forKey key: String,
                                forKey key: String,
                         retrieveImageTask: RetrieveImageTask,
                         retrieveImageTask: RetrieveImageTask,
                             progressBlock: DownloadProgressBlock?,
                             progressBlock: DownloadProgressBlock?,
-                        completionHandler: RetrieveCompletionHandler?,
+                        completionHandler: CompletionHandler?,
                                   options: KingfisherOptionsInfo?) -> RetrieveImageDownloadTask?
                                   options: KingfisherOptionsInfo?) -> RetrieveImageDownloadTask?
     {
     {
         let downloader = options?.downloader ?? self.downloader
         let downloader = options?.downloader ?? self.downloader
@@ -188,7 +187,7 @@ public class KingfisherManager {
                     // Not modified. Try to find the image from cache.
                     // Not modified. Try to find the image from cache.
                     // (The image should be in cache. It should be guaranteed by the framework users.)
                     // (The image should be in cache. It should be guaranteed by the framework users.)
                     targetCache.retrieveImageForKey(key, options: options, completionHandler: { (cacheImage, cacheType) -> () in
                     targetCache.retrieveImageForKey(key, options: options, completionHandler: { (cacheImage, cacheType) -> () in
-                        completionHandler?(image: cacheImage, error: nil, cacheType: cacheType, wasDownloaded: true, imageURL: URL)
+                        completionHandler?(image: cacheImage, error: nil, cacheType: cacheType, imageURL: URL)
                         
                         
                     })
                     })
                     return
                     return
@@ -198,7 +197,7 @@ public class KingfisherManager {
                     targetCache.storeImage(image, originalData: originalData, forKey: key, toDisk: !(options?.cacheMemoryOnly ?? false), completionHandler: nil)
                     targetCache.storeImage(image, originalData: originalData, forKey: key, toDisk: !(options?.cacheMemoryOnly ?? false), completionHandler: nil)
                 }
                 }
 
 
-                completionHandler?(image: image, error: error, cacheType: .none, wasDownloaded: true, imageURL: URL)
+                completionHandler?(image: image, error: error, cacheType: .none, imageURL: URL)
 
 
             })
             })
     }
     }
@@ -207,21 +206,20 @@ public class KingfisherManager {
                                    withURL URL: Foundation.URL,
                                    withURL URL: Foundation.URL,
                              retrieveImageTask: RetrieveImageTask,
                              retrieveImageTask: RetrieveImageTask,
                                  progressBlock: DownloadProgressBlock?,
                                  progressBlock: DownloadProgressBlock?,
-                             completionHandler: RetrieveCompletionHandler?,
+                             completionHandler: CompletionHandler?,
                                        options: KingfisherOptionsInfo?)
                                        options: KingfisherOptionsInfo?)
     {
     {
-        let diskTaskCompletionHandler: RetrieveCompletionHandler = {
-            (image, error, cacheType, wasDownloaded, imageURL) -> () in
+        let diskTaskCompletionHandler: CompletionHandler = { (image, error, cacheType, imageURL) -> () in
             // Break retain cycle created inside diskTask closure below
             // Break retain cycle created inside diskTask closure below
             retrieveImageTask.diskRetrieveTask = nil
             retrieveImageTask.diskRetrieveTask = nil
-            completionHandler?(image: image, error: error, cacheType: cacheType, wasDownloaded: wasDownloaded, imageURL: imageURL)
+            completionHandler?(image: image, error: error, cacheType: cacheType, imageURL: imageURL)
         }
         }
         
         
         let targetCache = options?.targetCache ?? cache
         let targetCache = options?.targetCache ?? cache
         let diskTask = targetCache.retrieveImageForKey(key, options: options,
         let diskTask = targetCache.retrieveImageForKey(key, options: options,
             completionHandler: { image, cacheType in
             completionHandler: { image, cacheType in
                 if image != nil {
                 if image != nil {
-                    diskTaskCompletionHandler(image: image, error: nil, cacheType:cacheType, wasDownloaded: false, imageURL: URL)
+                    diskTaskCompletionHandler(image: image, error: nil, cacheType:cacheType, imageURL: URL)
                 } else {
                 } else {
                     self.downloadAndCacheImageWithURL(URL,
                     self.downloadAndCacheImageWithURL(URL,
                         forKey: key,
                         forKey: key,

+ 2 - 2
Sources/UIButton+Kingfisher.swift

@@ -100,7 +100,7 @@ extension UIButton {
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
                 }
                 }
             },
             },
-            completionHandler: {[weak self] image, error, cacheType, _, imageURL in
+            completionHandler: {[weak self] image, error, cacheType, imageURL in
                 dispatch_async_safely_to_main_queue {
                 dispatch_async_safely_to_main_queue {
                     guard let sSelf = self, imageURL == sSelf.kf_webURLForState(state) else {
                     guard let sSelf = self, imageURL == sSelf.kf_webURLForState(state) else {
                         return
                         return
@@ -239,7 +239,7 @@ extension UIButton {
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
                 }
                 }
             },
             },
-            completionHandler: { [weak self] image, error, cacheType, _, imageURL in
+            completionHandler: { [weak self] image, error, cacheType, imageURL in
                 dispatch_async_safely_to_main_queue {
                 dispatch_async_safely_to_main_queue {
                     guard let sSelf = self, imageURL == sSelf.kf_backgroundWebURLForState(state) else {
                     guard let sSelf = self, imageURL == sSelf.kf_backgroundWebURLForState(state) else {
                         return
                         return