SDAnimatedImageView+WebCache.m 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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+WebCache.h"
  9. #if SD_UIKIT || SD_MAC
  10. #import "UIView+WebCache.h"
  11. #import "SDAnimatedImage.h"
  12. @implementation SDAnimatedImageView (WebCache)
  13. - (void)sd_setImageWithURL:(nullable NSURL *)url {
  14. [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
  15. }
  16. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder {
  17. [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
  18. }
  19. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options {
  20. [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil];
  21. }
  22. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context {
  23. [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:context progress:nil completed:nil];
  24. }
  25. - (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock {
  26. [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock];
  27. }
  28. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock {
  29. [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock];
  30. }
  31. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock {
  32. [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
  33. }
  34. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
  35. [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
  36. }
  37. - (void)sd_setImageWithURL:(nullable NSURL *)url
  38. placeholderImage:(nullable UIImage *)placeholder
  39. options:(SDWebImageOptions)options
  40. context:(nullable SDWebImageContext *)context
  41. progress:(nullable SDImageLoaderProgressBlock)progressBlock
  42. completed:(nullable SDExternalCompletionBlock)completedBlock {
  43. Class animatedImageClass = [SDAnimatedImage class];
  44. SDWebImageMutableContext *mutableContext;
  45. if (context) {
  46. mutableContext = [context mutableCopy];
  47. } else {
  48. mutableContext = [NSMutableDictionary dictionary];
  49. }
  50. mutableContext[SDWebImageContextAnimatedImageClass] = animatedImageClass;
  51. [self sd_internalSetImageWithURL:url
  52. placeholderImage:placeholder
  53. options:options
  54. context:mutableContext
  55. setImageBlock:nil
  56. progress:progressBlock
  57. completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
  58. if (completedBlock) {
  59. completedBlock(image, error, cacheType, imageURL);
  60. }
  61. }];
  62. }
  63. @end
  64. #endif