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