FLAnimatedImageView+WebCache.m 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "FLAnimatedImageView+WebCache.h"
  9. #if SD_UIKIT
  10. #import "objc/runtime.h"
  11. #import "UIView+WebCacheOperation.h"
  12. #import "UIView+WebCache.h"
  13. #import "NSData+ImageContentType.h"
  14. #import "FLAnimatedImage.h"
  15. #import "UIImageView+WebCache.h"
  16. @implementation FLAnimatedImageView (WebCache)
  17. - (void)sd_setImageWithURL:(nullable NSURL *)url {
  18. [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
  19. }
  20. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder {
  21. [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
  22. }
  23. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options {
  24. [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil];
  25. }
  26. - (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock {
  27. [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock];
  28. }
  29. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock {
  30. [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock];
  31. }
  32. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock {
  33. [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
  34. }
  35. - (void)sd_setImageWithURL:(nullable NSURL *)url
  36. placeholderImage:(nullable UIImage *)placeholder
  37. options:(SDWebImageOptions)options
  38. progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
  39. completed:(nullable SDExternalCompletionBlock)completedBlock {
  40. __weak typeof(self)weakSelf = self;
  41. [self sd_internalSetImageWithURL:url
  42. placeholderImage:placeholder
  43. options:options
  44. operationKey:nil
  45. setImageBlock:^(UIImage *image, NSData *imageData) {
  46. SDImageFormat imageFormat = [NSData sd_imageFormatForImageData:imageData];
  47. if (imageFormat == SDImageFormatGIF) {
  48. weakSelf.animatedImage = [FLAnimatedImage animatedImageWithGIFData:imageData];
  49. weakSelf.image = nil;
  50. } else {
  51. weakSelf.image = image;
  52. weakSelf.animatedImage = nil;
  53. }
  54. }
  55. progress:progressBlock
  56. completed:completedBlock];
  57. }
  58. @end
  59. #endif