|
|
@@ -104,28 +104,14 @@ extension KingfisherWrapper where Base: ImageView {
|
|
|
if base.shouldPreloadAllAnimation() {
|
|
|
options.preloadAllAnimationData = true
|
|
|
}
|
|
|
-
|
|
|
- let progressive = ImageProgressiveProvider(
|
|
|
- options,
|
|
|
- isContinue: { () -> Bool in
|
|
|
- issuedIdentifier == self.taskIdentifier
|
|
|
- },
|
|
|
- isFinished: { () -> Bool in
|
|
|
- mutatingSelf.imageTask == nil
|
|
|
- },
|
|
|
- refreshImage: { (image) in
|
|
|
- self.base.image = image
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
+
|
|
|
+ options.onDataReceived?.forEach {
|
|
|
+ $0.onShouldApply = { issuedIdentifier == self.taskIdentifier }
|
|
|
+ }
|
|
|
+
|
|
|
let task = KingfisherManager.shared.retrieveImage(
|
|
|
with: source,
|
|
|
options: options,
|
|
|
- receivedBlock: { latest, received in
|
|
|
- guard issuedIdentifier == self.taskIdentifier else { return }
|
|
|
- let callbacks = mutatingSelf.imageTask?.sessionTask.callbacks ?? []
|
|
|
- progressive.update(data: received, with: callbacks)
|
|
|
- },
|
|
|
progressBlock: { receivedSize, totalSize in
|
|
|
guard issuedIdentifier == self.taskIdentifier else { return }
|
|
|
progressBlock?(receivedSize, totalSize)
|
|
|
@@ -147,27 +133,25 @@ extension KingfisherWrapper where Base: ImageView {
|
|
|
}
|
|
|
|
|
|
mutatingSelf.imageTask = nil
|
|
|
-
|
|
|
- progressive.finished {
|
|
|
- switch result {
|
|
|
- case .success(let value):
|
|
|
- guard self.needsTransition(options: options, cacheType: value.cacheType) else {
|
|
|
- mutatingSelf.placeholder = nil
|
|
|
- self.base.image = value.image
|
|
|
- completionHandler?(result)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- self.makeTransition(image: value.image, transition: options.transition) {
|
|
|
- completionHandler?(result)
|
|
|
- }
|
|
|
-
|
|
|
- case .failure:
|
|
|
- if let image = options.onFailureImage {
|
|
|
- self.base.image = image
|
|
|
- }
|
|
|
+
|
|
|
+ switch result {
|
|
|
+ case .success(let value):
|
|
|
+ guard self.needsTransition(options: options, cacheType: value.cacheType) else {
|
|
|
+ mutatingSelf.placeholder = nil
|
|
|
+ self.base.image = value.image
|
|
|
completionHandler?(result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ self.makeTransition(image: value.image, transition: options.transition) {
|
|
|
+ completionHandler?(result)
|
|
|
+ }
|
|
|
+
|
|
|
+ case .failure:
|
|
|
+ if let image = options.onFailureImage {
|
|
|
+ self.base.image = image
|
|
|
}
|
|
|
+ completionHandler?(result)
|
|
|
}
|
|
|
}
|
|
|
}
|