Browse Source

Refactor for demo URLs

onevcat 6 years ago
parent
commit
29552d90a1

+ 0 - 5
Demo/Demo/Kingfisher-Demo/Info.plist

@@ -22,11 +22,6 @@
 	<string>1244</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
-	<key>NSAppTransportSecurity</key>
-	<dict>
-		<key>NSAllowsArbitraryLoads</key>
-		<true/>
-	</dict>
 	<key>UILaunchStoryboardName</key>
 	<string>LaunchScreen</string>
 	<key>UIMainStoryboardFile</key>

+ 11 - 6
Demo/Demo/Kingfisher-Demo/Resources/ImageLoader.swift

@@ -28,17 +28,22 @@ import Foundation
 
 struct ImageLoader {
     static let sampleImageURLs: [URL] = {
-        let prefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Loading/"
-        return (1...10).map { URL(string: "\(prefix)kingfisher-\($0).jpg")! }
+        let prefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Loading"
+        return (1...10).map { URL(string: "\(prefix)/kingfisher-\($0).jpg")! }
     }()
 
     static let highResolutionImageURLs: [URL] = {
-        let prefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/HighResolution/"
-        return (1...20).map { URL(string: "\(prefix)\($0).jpg")! }
+        let prefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/HighResolution"
+        return (1...20).map { URL(string: "\(prefix)/\($0).jpg")! }
     }()
     
     static let gifImageURLs: [URL] = {
-        let prefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/GIF/"
-        return (1...3).map { URL(string: "\(prefix)\($0).gif")! }
+        let prefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/GIF"
+        return (1...3).map { URL(string: "\(prefix)/\($0).gif")! }
+    }()
+
+    static let progressiveImageURL: URL = {
+        let prefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Progressive"
+        return URL(string: "\(prefix)/progressive.jpg")!
     }()
 }

+ 2 - 4
Demo/Demo/Kingfisher-Demo/ViewControllers/ProgressiveJPEGViewController.swift

@@ -36,8 +36,6 @@ class ProgressiveJPEGViewController: UIViewController {
     private var isWait = true
     private var isFastestScan = true
     
-    private let url = URL(string: "https://demo-resources.oss-cn-beijing.aliyuncs.com/progressive.jpg")!
-//    private let url = URL(string: "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Loading/kingfisher-9.jpg")!
     private let processor = RoundCornerImageProcessor(cornerRadius: 30)
     
     override func viewDidLoad() {
@@ -58,7 +56,7 @@ class ProgressiveJPEGViewController: UIViewController {
         )
         
         imageView.kf.setImage(
-            with: url,
+            with: ImageLoader.progressiveImageURL,
             placeholder: nil,
             options: [.loadDiskFileSynchronously,
                       .progressiveJPEG(progressive),
@@ -82,7 +80,7 @@ class ProgressiveJPEGViewController: UIViewController {
             imageView.kf.cancelDownloadTask()
             // Clean cache
             KingfisherManager.shared.cache.removeImage(
-                forKey: self.url.cacheKey,
+                forKey: ImageLoader.progressiveImageURL.cacheKey,
                 processorIdentifier: self.processor.identifier,
                 callbackQueue: .mainAsync,
                 completionHandler: {