HUWebImageDownloader.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // HUWebImageDownloader.h
  3. // HUPhotoBrowser
  4. //
  5. // Created by mac on 16/2/25.
  6. // Copyright (c) 2016年 hujewelz. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. typedef NS_ENUM(NSInteger, HUWebImageOption) {
  10. HUWebImageOptionNone,
  11. HUWebImageOptionMemoryOnely,
  12. HUWebImageOptionMemoryAndDisk,
  13. };
  14. typedef void(^HUDownloadCompletionBlock)( UIImage * __nullable image, NSError * __nullable error, NSURL * __nullable imageUrl);
  15. @class HUWebImageDownloadOperation;
  16. @interface HUWebImageDownloader : NSObject
  17. + (nonnull instancetype)sharedInstance;
  18. + (nonnull NSString *)cacheKeyForURL:(nonnull NSURL *)url;
  19. + (nullable UIImage *)imageFromDiskCacheForKey:(nonnull NSString *)key;
  20. + (nullable UIImage *)imageFromMemoryCacheForKey:(nonnull NSString *)key;
  21. + (nonnull HUWebImageDownloadOperation *)downloadImageWithURL:(nonnull NSURL *)url completed:(nullable HUDownloadCompletionBlock)completeBlock;
  22. + (nonnull HUWebImageDownloadOperation *)downloadImageWithURL:(nonnull NSURL *)url option:(HUWebImageOption)option completed:(nullable HUDownloadCompletionBlock)completeBlock;
  23. - (nonnull NSString *)cacheKeyForURL:(nonnull NSURL *)url;
  24. - (nullable UIImage *)imageFromDiskCacheForKey:(nonnull NSString *)key;
  25. - (nullable UIImage *)imageFromMemoryCacheForKey:(nonnull NSString *)key;
  26. - (void)saveImage:(nullable UIImage *)image forKey:(nonnull NSString *)key toDisk:(BOOL)toDisk;
  27. - (nonnull HUWebImageDownloadOperation *)downloadImageWithURL:(nonnull NSURL *)url completed:(nullable HUDownloadCompletionBlock)completeBlock;
  28. - (nonnull HUWebImageDownloadOperation *)downloadImageWithURL:(nonnull NSURL *)url option:(HUWebImageOption)option completed:(nullable HUDownloadCompletionBlock)completeBlock;
  29. @property (nonatomic) BOOL shouldCacheImagesInMemory;
  30. @end