SDAnimatedImageView+WebCache.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "SDAnimatedImageView.h"
  9. #if SD_UIKIT || SD_MAC
  10. #import "SDWebImageManager.h"
  11. /**
  12. Integrates SDWebImage async downloading and caching of remote images with SDAnimatedImageView.
  13. */
  14. @interface SDAnimatedImageView (WebCache)
  15. /**
  16. * Set the imageView `image` with an `url`.
  17. *
  18. * The download is asynchronous and cached.
  19. *
  20. * @param url The url for the image.
  21. */
  22. - (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT;
  23. /**
  24. * Set the imageView `image` with an `url` and a placeholder.
  25. *
  26. * The download is asynchronous and cached.
  27. *
  28. * @param url The url for the image.
  29. * @param placeholder The image to be set initially, until the image request finishes.
  30. * @see sd_setImageWithURL:placeholderImage:options:
  31. */
  32. - (void)sd_setImageWithURL:(nullable NSURL *)url
  33. placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT;
  34. /**
  35. * Set the imageView `image` with an `url`, placeholder and custom options.
  36. *
  37. * The download is asynchronous and cached.
  38. *
  39. * @param url The url for the image.
  40. * @param placeholder The image to be set initially, until the image request finishes.
  41. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  42. */
  43. - (void)sd_setImageWithURL:(nullable NSURL *)url
  44. placeholderImage:(nullable UIImage *)placeholder
  45. options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT;
  46. /**
  47. * Set the imageView `image` with an `url`, placeholder, custom options and context.
  48. *
  49. * The download is asynchronous and cached.
  50. *
  51. * @param url The url for the image.
  52. * @param placeholder The image to be set initially, until the image request finishes.
  53. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  54. * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
  55. */
  56. - (void)sd_setImageWithURL:(nullable NSURL *)url
  57. placeholderImage:(nullable UIImage *)placeholder
  58. options:(SDWebImageOptions)options
  59. context:(nullable SDWebImageContext *)context;
  60. /**
  61. * Set the imageView `image` with an `url`.
  62. *
  63. * The download is asynchronous and cached.
  64. *
  65. * @param url The url for the image.
  66. * @param completedBlock A block called when operation has been completed. This block has no return value
  67. * and takes the requested UIImage as first parameter. In case of error the image parameter
  68. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  69. * indicating if the image was retrieved from the local cache or from the network.
  70. * The fourth parameter is the original image url.
  71. */
  72. - (void)sd_setImageWithURL:(nullable NSURL *)url
  73. completed:(nullable SDExternalCompletionBlock)completedBlock;
  74. /**
  75. * Set the imageView `image` with an `url`, placeholder.
  76. *
  77. * The download is asynchronous and cached.
  78. *
  79. * @param url The url for the image.
  80. * @param placeholder The image to be set initially, until the image request finishes.
  81. * @param completedBlock A block called when operation has been completed. This block has no return value
  82. * and takes the requested UIImage as first parameter. In case of error the image parameter
  83. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  84. * indicating if the image was retrieved from the local cache or from the network.
  85. * The fourth parameter is the original image url.
  86. */
  87. - (void)sd_setImageWithURL:(nullable NSURL *)url
  88. placeholderImage:(nullable UIImage *)placeholder
  89. completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT;
  90. /**
  91. * Set the imageView `image` with an `url`, placeholder and custom options.
  92. *
  93. * The download is asynchronous and cached.
  94. *
  95. * @param url The url for the image.
  96. * @param placeholder The image to be set initially, until the image request finishes.
  97. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  98. * @param completedBlock A block called when operation has been completed. This block has no return value
  99. * and takes the requested UIImage as first parameter. In case of error the image parameter
  100. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  101. * indicating if the image was retrieved from the local cache or from the network.
  102. * The fourth parameter is the original image url.
  103. */
  104. - (void)sd_setImageWithURL:(nullable NSURL *)url
  105. placeholderImage:(nullable UIImage *)placeholder
  106. options:(SDWebImageOptions)options
  107. completed:(nullable SDExternalCompletionBlock)completedBlock;
  108. /**
  109. * Set the imageView `image` with an `url`, placeholder and custom options.
  110. *
  111. * The download is asynchronous and cached.
  112. *
  113. * @param url The url for the image.
  114. * @param placeholder The image to be set initially, until the image request finishes.
  115. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  116. * @param progressBlock A block called while image is downloading
  117. * @note the progress block is executed on a background queue
  118. * @param completedBlock A block called when operation has been completed. This block has no return value
  119. * and takes the requested UIImage as first parameter. In case of error the image parameter
  120. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  121. * indicating if the image was retrieved from the local cache or from the network.
  122. * The fourth parameter is the original image url.
  123. */
  124. - (void)sd_setImageWithURL:(nullable NSURL *)url
  125. placeholderImage:(nullable UIImage *)placeholder
  126. options:(SDWebImageOptions)options
  127. progress:(nullable SDImageLoaderProgressBlock)progressBlock
  128. completed:(nullable SDExternalCompletionBlock)completedBlock;
  129. /**
  130. * Set the imageView `image` with an `url`, placeholder, custom options and context.
  131. *
  132. * The download is asynchronous and cached.
  133. *
  134. * @param url The url for the image.
  135. * @param placeholder The image to be set initially, until the image request finishes.
  136. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  137. * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
  138. * @param progressBlock A block called while image is downloading
  139. * @note the progress block is executed on a background queue
  140. * @param completedBlock A block called when operation has been completed. This block has no return value
  141. * and takes the requested UIImage as first parameter. In case of error the image parameter
  142. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  143. * indicating if the image was retrieved from the local cache or from the network.
  144. * The fourth parameter is the original image url.
  145. */
  146. - (void)sd_setImageWithURL:(nullable NSURL *)url
  147. placeholderImage:(nullable UIImage *)placeholder
  148. options:(SDWebImageOptions)options
  149. context:(nullable SDWebImageContext *)context
  150. progress:(nullable SDImageLoaderProgressBlock)progressBlock
  151. completed:(nullable SDExternalCompletionBlock)completedBlock;
  152. @end
  153. #endif