Skip to content

Commit

Permalink
Fix PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaharHD committed May 8, 2017
1 parent f9e975b commit 63c4bac
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
17 changes: 13 additions & 4 deletions Sources/AnimatedImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ open class AnimatedImageView: UIImageView {
super.didMoveToSuperview()
didMove()
}
// This is for back compatibility that using regular UIImageView to show GIF.
override func shouldPreloadAllGIF() -> Bool {

// This is for back compatibility that using regular UIImageView to show animated image.
override func shouldPreloadAllAnimation() -> Bool {
return false
}

// MARK: - Private method
/// Reset the animator.
private func reset() {
Expand Down Expand Up @@ -353,3 +353,12 @@ extension Array {
private func pure<T>(_ value: T) -> [T] {
return [value]
}

// MARK: - Deprecated. Only for back compatibility.
extension AnimatedImageView {
// This is for back compatibility that using regular UIImageView to show GIF.
@available(*, deprecated, renamed: "shouldPreloadAllAnimation")
override func shouldPreloadAllGIF() -> Bool {
return false
}
}
5 changes: 0 additions & 5 deletions Sources/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,6 @@ extension Kingfisher where Base: Image {

return image
}

@available(*, deprecated, message: "preloadAllGIFData is now preloadAllAnimationData")
static func image(data: Data, scale: CGFloat, preloadAllGIFData: Bool, onlyFirstFrame: Bool) -> Image? {
return image(data: data, scale: scale, preloadAllAnimationData: preloadAllGIFData, onlyFirstFrame: onlyFirstFrame)
}
}

// MARK: - Image Transforming
Expand Down
2 changes: 0 additions & 2 deletions Sources/ImageView+Kingfisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@ extension ImageView {
fileprivate func kf_setImageTask(_ task: RetrieveImageTask?) { kf.setImageTask(task) }
@available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.setWebURL")
fileprivate func kf_setWebURL(_ url: URL) { kf.setWebURL(url) }
}

extension ImageView {
func shouldPreloadAllAnimation() -> Bool { return true }

@available(*, deprecated, renamed: "shouldPreloadAllAnimation")
Expand Down
25 changes: 15 additions & 10 deletions Sources/KingfisherOptionsInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ public enum KingfisherOptionsInfoItem {
/// all data, while a normal image view (`UIImageView` or `NSImageView`) will load all data. Choose to use
/// corresponding image view type instead of setting this option.
case preloadAllAnimationData

/// Back compatibility for deprecated preloadAllGIFData
@available(*, deprecated, renamed: "preloadAllAnimation")
static let preloadAllGIFData = KingfisherOptionsInfoItem.preloadAllAnimationData

/// The `ImageDownloadRequestModifier` contained will be used to change the request before it being sent.
/// This is the last chance you can modify the request. You can modify the request for some customizing purpose,
Expand Down Expand Up @@ -237,12 +233,6 @@ public extension Collection where Iterator.Element == KingfisherOptionsInfoItem
public var preloadAllAnimationData: Bool {
return contains { $0 <== .preloadAllAnimationData }
}

/// Whether the image data should be all loaded at once if it is a GIF.
@available(*, deprecated, renamed: "preloadAllAnimation")
public var preloadAllGIFData: Bool {
return contains { $0 <== .preloadAllAnimationData }
}

/// The queue of callbacks should happen from Kingfisher.
public var callbackDispatchQueue: DispatchQueue {
Expand Down Expand Up @@ -304,3 +294,18 @@ public extension Collection where Iterator.Element == KingfisherOptionsInfoItem
return contains { $0 <== .onlyLoadFirstFrame }
}
}

// MARK: - Deprecated. Only for back compatibility.
public extension Collection where Iterator.Element == KingfisherOptionsInfoItem {

/// Whether the image data should be all loaded at once if it is a GIF.
@available(*, deprecated, renamed: "preloadAllAnimationData")
public var preloadAllGIFData: Bool {
return preloadAllAnimationData
}
}

public extension KingfisherOptionsInfoItem {
@available(*, deprecated, renamed: "preloadAllAnimationData")
static let preloadAllGIFData = KingfisherOptionsInfoItem.preloadAllAnimationData
}
2 changes: 1 addition & 1 deletion Tests/KingfisherTests/ImageExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ImageExtensionTests: XCTestCase {
#endif
}

func testPreloadAllGIFData() {
func testPreloadAllAnimationData() {
let image = Kingfisher<Image>.animated(with: testImageSingleFrameGIFData, preloadAll: true)!
XCTAssertNotNil(image, "The image should be initiated.")
#if os(iOS) || os(tvOS)
Expand Down

0 comments on commit 63c4bac

Please sign in to comment.