Deprecated.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. //
  2. // Deprecated.swift
  3. // Kingfisher
  4. //
  5. // Created by onevcat on 2018/09/28.
  6. //
  7. // Copyright (c) 2018 Wei Wang <onevcat@gmail.com>
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining a copy
  10. // of this software and associated documentation files (the "Software"), to deal
  11. // in the Software without restriction, including without limitation the rights
  12. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. // copies of the Software, and to permit persons to whom the Software is
  14. // furnished to do so, subject to the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be included in
  17. // all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. // THE SOFTWARE.
  26. #if canImport(AppKit)
  27. import AppKit
  28. #elseif canImport(UIKit)
  29. import UIKit
  30. #endif
  31. extension KingfisherWrapper where Base: Image {
  32. @available(*, deprecated, message:
  33. "Will be removed soon. Pass parameters with `ImageCreatingOptions`, use `image(with:options:)` instead.")
  34. public static func image(
  35. data: Data,
  36. scale: CGFloat,
  37. preloadAllAnimationData: Bool,
  38. onlyFirstFrame: Bool) -> Image?
  39. {
  40. let options = ImageCreatingOptions(
  41. scale: scale,
  42. duration: 0.0,
  43. preloadAll: preloadAllAnimationData,
  44. onlyFirstFrame: onlyFirstFrame)
  45. return KingfisherWrapper.image(data: data, options: options)
  46. }
  47. @available(*, deprecated, message:
  48. "Will be removed soon. Pass parameters with `ImageCreatingOptions`, use `animatedImage(with:options:)` instead.")
  49. public static func animated(
  50. with data: Data,
  51. scale: CGFloat = 1.0,
  52. duration: TimeInterval = 0.0,
  53. preloadAll: Bool,
  54. onlyFirstFrame: Bool = false) -> Image?
  55. {
  56. let options = ImageCreatingOptions(
  57. scale: scale, duration: duration, preloadAll: preloadAll, onlyFirstFrame: onlyFirstFrame)
  58. return animatedImage(data: data, options: options)
  59. }
  60. }
  61. @available(*, deprecated, message: "Will be removed soon. Use `Result<RetrieveImageResult>` based callback instead")
  62. public typealias CompletionHandler =
  63. ((_ image: Image?, _ error: NSError?, _ cacheType: CacheType, _ imageURL: URL?) -> Void)
  64. @available(*, deprecated, message: "Will be removed soon. Use `Result<ImageLoadingResult>` based callback instead")
  65. public typealias ImageDownloaderCompletionHandler =
  66. ((_ image: Image?, _ error: NSError?, _ url: URL?, _ originalData: Data?) -> Void)
  67. @available(*, deprecated, message: "Will be removed soon. Use `DownloadTask` to cancel a task.")
  68. extension RetrieveImageTask {
  69. @available(*, deprecated, message: "RetrieveImageTask.empty will be removed soon. Use `nil` to represnt a no task.")
  70. public static let empty = RetrieveImageTask()
  71. }
  72. extension KingfisherManager {
  73. /// Get an image with resource.
  74. /// If `.empty` is used as `options`, Kingfisher will seek the image in memory and disk first.
  75. /// If not found, it will download the image at `resource.downloadURL` and cache it with `resource.cacheKey`.
  76. /// These default behaviors could be adjusted by passing different options. See `KingfisherOptions` for more.
  77. ///
  78. /// - Parameters:
  79. /// - resource: Resource object contains information such as `cacheKey` and `downloadURL`.
  80. /// - options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more.
  81. /// - progressBlock: Called every time downloaded data changed. This could be used as a progress UI.
  82. /// - completionHandler: Called when the whole retrieving process finished.
  83. /// - Returns: A `RetrieveImageTask` task object. You can use this object to cancel the task.
  84. @available(*, deprecated, message: "Use `Result` based callback instead.")
  85. @discardableResult
  86. public func retrieveImage(with resource: Resource,
  87. options: KingfisherOptionsInfo?,
  88. progressBlock: DownloadProgressBlock?,
  89. completionHandler: CompletionHandler?) -> DownloadTask?
  90. {
  91. return retrieveImage(with: resource, options: options, progressBlock: progressBlock) {
  92. result in
  93. switch result {
  94. case .success(let value): completionHandler?(value.image, nil, value.cacheType, value.imageURL)
  95. case .failure(let error): completionHandler?(nil, error as NSError, .none, resource.downloadURL)
  96. }
  97. }
  98. }
  99. }
  100. extension ImageDownloader {
  101. @available(*, deprecated, message: "Use `Result` based callback instead.")
  102. @discardableResult
  103. open func downloadImage(with url: URL,
  104. retrieveImageTask: RetrieveImageTask? = nil,
  105. options: KingfisherOptionsInfo? = nil,
  106. progressBlock: ImageDownloaderProgressBlock? = nil,
  107. completionHandler: ImageDownloaderCompletionHandler?) -> DownloadTask?
  108. {
  109. return downloadImage(with: url, options: options, progressBlock: progressBlock) {
  110. result in
  111. switch result {
  112. case .success(let value): completionHandler?(value.image, nil, value.url, value.originalData)
  113. case .failure(let error): completionHandler?(nil, error as NSError, nil, nil)
  114. }
  115. }
  116. }
  117. }
  118. @available(*, deprecated, message: "RetrieveImageDownloadTask is removed. Use `DownloadTask` to cancel a task.")
  119. public struct RetrieveImageDownloadTask {
  120. }
  121. @available(*, deprecated, message: "RetrieveImageTask is removed. Use `DownloadTask` to cancel a task.")
  122. public final class RetrieveImageTask {
  123. }
  124. @available(*, deprecated, message: "Use `DownloadProgressBlock` instead.", renamed: "DownloadProgressBlock")
  125. public typealias ImageDownloaderProgressBlock = DownloadProgressBlock
  126. #if !os(watchOS)
  127. extension KingfisherWrapper where Base: ImageView {
  128. @available(*, deprecated, message: "Use `Result` based callback instead.")
  129. @discardableResult
  130. public func setImage(with resource: Resource?,
  131. placeholder: Placeholder? = nil,
  132. options: KingfisherOptionsInfo? = nil,
  133. progressBlock: DownloadProgressBlock? = nil,
  134. completionHandler: CompletionHandler?) -> DownloadTask?
  135. {
  136. return setImage(with: resource, placeholder: placeholder, options: options, progressBlock: progressBlock) {
  137. result in
  138. switch result {
  139. case .success(let value):
  140. completionHandler?(value.image, nil, value.cacheType, value.imageURL)
  141. case .failure(let error):
  142. completionHandler?(nil, error as NSError, .none, nil)
  143. }
  144. }
  145. }
  146. }
  147. #endif
  148. #if canImport(UIKit) && !os(watchOS)
  149. extension KingfisherWrapper where Base: UIButton {
  150. @available(*, deprecated, message: "Use `Result` based callback instead.")
  151. @discardableResult
  152. public func setImage(
  153. with resource: Resource?,
  154. for state: UIControl.State,
  155. placeholder: UIImage? = nil,
  156. options: KingfisherOptionsInfo? = nil,
  157. progressBlock: DownloadProgressBlock? = nil,
  158. completionHandler: CompletionHandler?) -> DownloadTask?
  159. {
  160. return setImage(
  161. with: resource,
  162. for: state,
  163. placeholder: placeholder,
  164. options: options,
  165. progressBlock: progressBlock)
  166. {
  167. result in
  168. switch result {
  169. case .success(let value):
  170. completionHandler?(value.image, nil, value.cacheType, value.imageURL)
  171. case .failure(let error):
  172. completionHandler?(nil, error as NSError, .none, nil)
  173. }
  174. }
  175. }
  176. @available(*, deprecated, message: "Use `Result` based callback instead.")
  177. @discardableResult
  178. public func setBackgroundImage(
  179. with resource: Resource?,
  180. for state: UIControl.State,
  181. placeholder: UIImage? = nil,
  182. options: KingfisherOptionsInfo? = nil,
  183. progressBlock: DownloadProgressBlock? = nil,
  184. completionHandler: CompletionHandler?) -> DownloadTask?
  185. {
  186. return setBackgroundImage(
  187. with: resource,
  188. for: state,
  189. placeholder: placeholder,
  190. options: options,
  191. progressBlock: progressBlock)
  192. {
  193. result in
  194. switch result {
  195. case .success(let value):
  196. completionHandler?(value.image, nil, value.cacheType, value.imageURL)
  197. case .failure(let error):
  198. completionHandler?(nil, error as NSError, .none, nil)
  199. }
  200. }
  201. }
  202. }
  203. #endif
  204. #if os(watchOS)
  205. import WatchKit
  206. extension KingfisherWrapper where Base: WKInterfaceImage {
  207. @available(*, deprecated, message: "Use `Result` based callback instead.")
  208. @discardableResult
  209. public func setImage(_ resource: Resource?,
  210. placeholder: Image? = nil,
  211. options: KingfisherOptionsInfo? = nil,
  212. progressBlock: DownloadProgressBlock? = nil,
  213. completionHandler: CompletionHandler?) -> DownloadTask?
  214. {
  215. return setImage(
  216. with: resource,
  217. placeholder: placeholder,
  218. options: options,
  219. progressBlock: progressBlock)
  220. {
  221. result in
  222. switch result {
  223. case .success(let value):
  224. completionHandler?(value.image, nil, value.cacheType, value.imageURL)
  225. case .failure(let error):
  226. completionHandler?(nil, error as NSError, .none, nil)
  227. }
  228. }
  229. }
  230. }
  231. #endif
  232. #if os(macOS)
  233. extension KingfisherWrapper where Base: NSButton {
  234. @discardableResult
  235. @available(*, deprecated, message: "Use `Result` based callback instead.")
  236. public func setImage(with resource: Resource?,
  237. placeholder: Image? = nil,
  238. options: KingfisherOptionsInfo? = nil,
  239. progressBlock: DownloadProgressBlock? = nil,
  240. completionHandler: CompletionHandler?) -> DownloadTask?
  241. {
  242. return setImage(
  243. with: resource,
  244. placeholder: placeholder,
  245. options: options,
  246. progressBlock: progressBlock)
  247. {
  248. result in
  249. switch result {
  250. case .success(let value):
  251. completionHandler?(value.image, nil, value.cacheType, value.imageURL)
  252. case .failure(let error):
  253. completionHandler?(nil, error as NSError, .none, nil)
  254. }
  255. }
  256. }
  257. @discardableResult
  258. @available(*, deprecated, message: "Use `Result` based callback instead.")
  259. public func setAlternateImage(with resource: Resource?,
  260. placeholder: Image? = nil,
  261. options: KingfisherOptionsInfo? = nil,
  262. progressBlock: DownloadProgressBlock? = nil,
  263. completionHandler: CompletionHandler?) -> DownloadTask?
  264. {
  265. return setAlternateImage(
  266. with: resource,
  267. placeholder: placeholder,
  268. options: options,
  269. progressBlock: progressBlock)
  270. {
  271. result in
  272. switch result {
  273. case .success(let value):
  274. completionHandler?(value.image, nil, value.cacheType, value.imageURL)
  275. case .failure(let error):
  276. completionHandler?(nil, error as NSError, .none, nil)
  277. }
  278. }
  279. }
  280. }
  281. #endif
  282. extension ImageCache {
  283. /// The largest cache cost of memory cache. The total cost is pixel count of
  284. /// all cached images in memory.
  285. /// Default is unlimited. Memory cache will be purged automatically when a
  286. /// memory warning notification is received.
  287. @available(*, deprecated, message: "Use `memoryStorage.config.totalCostLimit` instead.",
  288. renamed: "memoryStorage.config.totalCostLimit")
  289. open var maxMemoryCost: Int {
  290. get { return memoryStorage.config.totalCostLimit }
  291. set { memoryStorage.config.totalCostLimit = newValue }
  292. }
  293. /// The default DiskCachePathClosure
  294. @available(*, deprecated, message: "Not needed anymore.")
  295. public final class func defaultDiskCachePathClosure(path: String?, cacheName: String) -> String {
  296. let dstPath = path ?? NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!
  297. return (dstPath as NSString).appendingPathComponent(cacheName)
  298. }
  299. /// The default file extension appended to cached files.
  300. @available(*, deprecated, message: "Use `diskStorage.config.pathExtension` instead.",
  301. renamed: "diskStorage.config.pathExtension")
  302. open var pathExtension: String? {
  303. get { return diskStorage.config.pathExtension }
  304. set { diskStorage.config.pathExtension = newValue }
  305. }
  306. ///The disk cache location.
  307. @available(*, deprecated, message: "Use `diskStorage.directoryURL.absoluteString` instead.",
  308. renamed: "diskStorage.directoryURL.absoluteString")
  309. public var diskCachePath: String {
  310. return diskStorage.directoryURL.absoluteString
  311. }
  312. /// The largest disk size can be taken for the cache. It is the total
  313. /// allocated size of cached files in bytes.
  314. /// Default is no limit.
  315. @available(*, deprecated, message: "Use `diskStorage.config.sizeLimit` instead.",
  316. renamed: "diskStorage.config.sizeLimit")
  317. open var maxDiskCacheSize: UInt {
  318. get { return UInt(diskStorage.config.sizeLimit) }
  319. set { diskStorage.config.sizeLimit = newValue }
  320. }
  321. @available(*, deprecated, message: "Use `diskStorage.cacheFileURL(forKey:).path` instead.",
  322. renamed: "diskStorage.cacheFileURL(forKey:)")
  323. open func cachePath(forComputedKey key: String) -> String {
  324. return diskStorage.cacheFileURL(forKey: key).path
  325. }
  326. /**
  327. Get an image for a key from disk.
  328. - parameter key: Key for the image.
  329. - parameter options: Options of retrieving image. If you need to retrieve an image which was
  330. stored with a specified `ImageProcessor`, pass the processor in the option too.
  331. - returns: The image object if it is cached, or `nil` if there is no such key in the cache.
  332. */
  333. @available(*, deprecated,
  334. message: "Use `Result` based `retrieveImageInDiskCache(forKey:options:callbackQueue:completionHandler:)` instead.",
  335. renamed: "retrieveImageInDiskCache(forKey:options:callbackQueue:completionHandler:)")
  336. open func retrieveImageInDiskCache(forKey key: String, options: KingfisherOptionsInfo? = nil) -> Image? {
  337. let options = options ?? .empty
  338. let computedKey = key.computedKey(with: options.processor.identifier)
  339. do {
  340. if let data = try diskStorage.value(forKey: computedKey) {
  341. return options.cacheSerializer.image(with: data, options: options)
  342. }
  343. } catch {}
  344. return nil
  345. }
  346. @available(*, deprecated,
  347. message: "Use `Result` based `retrieveImage(forKey:options:callbackQueue:completionHandler:)` instead.",
  348. renamed: "retrieveImage(forKey:options:callbackQueue:completionHandler:)")
  349. open func retrieveImage(forKey key: String,
  350. options: KingfisherOptionsInfo?,
  351. completionHandler: ((Image?, CacheType) -> Void)?)
  352. {
  353. retrieveImage(
  354. forKey: key,
  355. options: options,
  356. callbackQueue: .dispatch((options ?? .empty).callbackDispatchQueue))
  357. {
  358. result in
  359. completionHandler?(result.value?.image, result.value?.cacheType ?? .none)
  360. }
  361. }
  362. /// The longest time duration in second of the cache being stored in disk.
  363. /// Default is 1 week (60 * 60 * 24 * 7 seconds).
  364. /// Setting this to a negative value will make the disk cache never expiring.
  365. @available(*, deprecated, message: "Deprecated. Use `diskStorage.config.expiration` instead")
  366. open var maxCachePeriodInSecond: TimeInterval {
  367. get { return diskStorage.config.expiration.timeInterval }
  368. set { diskStorage.config.expiration = .seconds(newValue) }
  369. }
  370. }
  371. extension ImageCache {
  372. @available(*, deprecated, message: "Use `Result` based callback instead.")
  373. open func store(_ image: Image,
  374. original: Data? = nil,
  375. forKey key: String,
  376. processorIdentifier identifier: String = "",
  377. cacheSerializer serializer: CacheSerializer = DefaultCacheSerializer.default,
  378. toDisk: Bool = true,
  379. completionHandler: (() -> Void)?)
  380. {
  381. store(
  382. image,
  383. original: original,
  384. forKey: key,
  385. processorIdentifier: identifier,
  386. cacheSerializer: serializer,
  387. toDisk: toDisk)
  388. {
  389. _ in
  390. completionHandler?()
  391. }
  392. }
  393. @available(*, deprecated, message: "Use the `Result`-based `calculateDiskStorageSize` instead.")
  394. open func calculateDiskCacheSize(completion handler: @escaping ((_ size: UInt) -> Void)) {
  395. calculateDiskStorageSize { result in
  396. handler(result.value ?? 0)
  397. }
  398. }
  399. }
  400. public extension Collection where Iterator.Element == KingfisherOptionsInfoItem {
  401. /// The queue of callbacks should happen from Kingfisher.
  402. @available(*, deprecated, message: "Use `callbackQueue` instead.", renamed: "callbackQueue")
  403. public var callbackDispatchQueue: DispatchQueue {
  404. return KingfisherParsedOptionsInfo(Array(self)).callbackQueue.queue
  405. }
  406. }
  407. /// Error domain of Kingfisher
  408. @available(*, deprecated, message: "Use `KingfisherError.domain` instead.", renamed: "KingfisherError.domain")
  409. public let KingfisherErrorDomain = "com.onevcat.Kingfisher.Error"
  410. /// Key will be used in the `userInfo` of `.invalidStatusCode`
  411. @available(*, unavailable,
  412. message: "Use `.invalidHTTPStatusCode` or `isInvalidResponseStatusCode` of `KingfisherError` instead for the status code.")
  413. public let KingfisherErrorStatusCodeKey = "statusCode"
  414. public extension Collection where Iterator.Element == KingfisherOptionsInfoItem {
  415. /// The target `ImageCache` which is used.
  416. @available(*, deprecated,
  417. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `targetCache` instead.")
  418. public var targetCache: ImageCache? {
  419. return KingfisherParsedOptionsInfo(Array(self)).targetCache
  420. }
  421. /// The original `ImageCache` which is used.
  422. @available(*, deprecated,
  423. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `originalCache` instead.")
  424. public var originalCache: ImageCache? {
  425. return KingfisherParsedOptionsInfo(Array(self)).originalCache
  426. }
  427. /// The `ImageDownloader` which is specified.
  428. @available(*, deprecated,
  429. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `downloader` instead.")
  430. public var downloader: ImageDownloader? {
  431. return KingfisherParsedOptionsInfo(Array(self)).downloader
  432. }
  433. /// Member for animation transition when using UIImageView.
  434. @available(*, deprecated,
  435. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `transition` instead.")
  436. public var transition: ImageTransition {
  437. return KingfisherParsedOptionsInfo(Array(self)).transition
  438. }
  439. /// A `Float` value set as the priority of image download task. The value for it should be
  440. /// between 0.0~1.0.
  441. @available(*, deprecated,
  442. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `downloadPriority` instead.")
  443. public var downloadPriority: Float {
  444. return KingfisherParsedOptionsInfo(Array(self)).downloadPriority
  445. }
  446. /// Whether an image will be always downloaded again or not.
  447. @available(*, deprecated,
  448. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `forceRefresh` instead.")
  449. public var forceRefresh: Bool {
  450. return KingfisherParsedOptionsInfo(Array(self)).forceRefresh
  451. }
  452. /// Whether an image should be got only from memory cache or download.
  453. @available(*, deprecated,
  454. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `fromMemoryCacheOrRefresh` instead.")
  455. public var fromMemoryCacheOrRefresh: Bool {
  456. return KingfisherParsedOptionsInfo(Array(self)).fromMemoryCacheOrRefresh
  457. }
  458. /// Whether the transition should always happen or not.
  459. @available(*, deprecated,
  460. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `forceTransition` instead.")
  461. public var forceTransition: Bool {
  462. return KingfisherParsedOptionsInfo(Array(self)).forceTransition
  463. }
  464. /// Whether cache the image only in memory or not.
  465. @available(*, deprecated,
  466. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `cacheMemoryOnly` instead.")
  467. public var cacheMemoryOnly: Bool {
  468. return KingfisherParsedOptionsInfo(Array(self)).cacheMemoryOnly
  469. }
  470. /// Whether the caching operation will be waited or not.
  471. @available(*, deprecated,
  472. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `waitForCache` instead.")
  473. public var waitForCache: Bool {
  474. return KingfisherParsedOptionsInfo(Array(self)).waitForCache
  475. }
  476. /// Whether only load the images from cache or not.
  477. @available(*, deprecated,
  478. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `onlyFromCache` instead.")
  479. public var onlyFromCache: Bool {
  480. return KingfisherParsedOptionsInfo(Array(self)).onlyFromCache
  481. }
  482. /// Whether the image should be decoded in background or not.
  483. @available(*, deprecated,
  484. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `backgroundDecode` instead.")
  485. public var backgroundDecode: Bool {
  486. return KingfisherParsedOptionsInfo(Array(self)).backgroundDecode
  487. }
  488. /// Whether the image data should be all loaded at once if it is an animated image.
  489. @available(*, deprecated,
  490. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `preloadAllAnimationData` instead.")
  491. public var preloadAllAnimationData: Bool {
  492. return KingfisherParsedOptionsInfo(Array(self)).preloadAllAnimationData
  493. }
  494. /// The `CallbackQueue` on which completion handler should be invoked.
  495. /// If not set in the options, `.mainCurrentOrAsync` will be used.
  496. @available(*, deprecated,
  497. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `callbackQueue` instead.")
  498. public var callbackQueue: CallbackQueue {
  499. return KingfisherParsedOptionsInfo(Array(self)).callbackQueue
  500. }
  501. /// The scale factor which should be used for the image.
  502. @available(*, deprecated,
  503. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `scaleFactor` instead.")
  504. public var scaleFactor: CGFloat {
  505. return KingfisherParsedOptionsInfo(Array(self)).scaleFactor
  506. }
  507. /// The `ImageDownloadRequestModifier` will be used before sending a download request.
  508. @available(*, deprecated,
  509. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `requestModifier` instead.")
  510. public var modifier: ImageDownloadRequestModifier {
  511. return KingfisherParsedOptionsInfo(Array(self)).requestModifier
  512. }
  513. /// `ImageProcessor` for processing when the downloading finishes.
  514. @available(*, deprecated,
  515. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `processor` instead.")
  516. public var processor: ImageProcessor {
  517. return KingfisherParsedOptionsInfo(Array(self)).processor
  518. }
  519. /// `ImageModifier` for modifying right before the image is displayed.
  520. @available(*, deprecated,
  521. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `imageModifier` instead.")
  522. public var imageModifier: ImageModifier {
  523. return KingfisherParsedOptionsInfo(Array(self)).imageModifier
  524. }
  525. /// `CacheSerializer` to convert image to data for storing in cache.
  526. @available(*, deprecated,
  527. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `cacheSerializer` instead.")
  528. public var cacheSerializer: CacheSerializer {
  529. return KingfisherParsedOptionsInfo(Array(self)).cacheSerializer
  530. }
  531. /// Keep the existing image while setting another image to an image view.
  532. /// Or the placeholder will be used while downloading.
  533. @available(*, deprecated,
  534. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `keepCurrentImageWhileLoading` instead.")
  535. public var keepCurrentImageWhileLoading: Bool {
  536. return KingfisherParsedOptionsInfo(Array(self)).keepCurrentImageWhileLoading
  537. }
  538. /// Whether the options contains `.onlyLoadFirstFrame`.
  539. @available(*, deprecated,
  540. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `onlyLoadFirstFrame` instead.")
  541. public var onlyLoadFirstFrame: Bool {
  542. return KingfisherParsedOptionsInfo(Array(self)).onlyLoadFirstFrame
  543. }
  544. /// Whether the options contains `.cacheOriginalImage`.
  545. @available(*, deprecated,
  546. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `cacheOriginalImage` instead.")
  547. public var cacheOriginalImage: Bool {
  548. return KingfisherParsedOptionsInfo(Array(self)).cacheOriginalImage
  549. }
  550. /// The image which should be used when download image request fails.
  551. @available(*, deprecated,
  552. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `onFailureImage` instead.")
  553. public var onFailureImage: Optional<Image?> {
  554. return KingfisherParsedOptionsInfo(Array(self)).onFailureImage
  555. }
  556. /// Whether the `ImagePrefetcher` should load images to memory in an aggressive way or not.
  557. @available(*, deprecated,
  558. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `alsoPrefetchToMemory` instead.")
  559. public var alsoPrefetchToMemory: Bool {
  560. return KingfisherParsedOptionsInfo(Array(self)).alsoPrefetchToMemory
  561. }
  562. /// Whether the disk storage file loading should happen in a synchronous behavior or not.
  563. @available(*, deprecated,
  564. message: "Create a `KingfisherParsedOptionsInfo` from `KingfisherOptionsInfo` and use `loadDiskFileSynchronously` instead.")
  565. public var loadDiskFileSynchronously: Bool {
  566. return KingfisherParsedOptionsInfo(Array(self)).loadDiskFileSynchronously
  567. }
  568. }