HBHttpImageDownloaderOperation.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // HBHttpImageDownloaderOperation.h
  3. // MyTest
  4. //
  5. // Created by weqia on 13-8-21.
  6. // Copyright (c) 2013年 weqia. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #define HBHttpImageDownloadStartNotification @"HBHttpImageDownloadStartNotification"
  10. #define HBHttpImageDownloadStopNotification @"HBHttpImageDownloadStopNotification"
  11. typedef void(^HBHttpImageDownloaderProcessBlock)(NSUInteger,long long);
  12. typedef void(^HBHttpImageDownloaderCompleteBlock)(UIImage*,NSData*,NSError*,BOOL);
  13. typedef void(^HBHttpImageDownloaderCancelBlock)();
  14. typedef enum {
  15. HBHttpImageDownloaderOptionRetry=1<<0,
  16. /**
  17. * 低优先级
  18. **/
  19. HBHttpImageDownloaderOptionLowPriority=1<<1,
  20. /**
  21. * 缓存中加载
  22. **/
  23. HBHttpImageDownloaderOptionUseCache=1<<3,
  24. /**
  25. * 显示加载过程
  26. **/
  27. HBHttpImageDownloaderOptionProgressiveDownload=1<<4
  28. }HBHttpImageDownloaderOption;
  29. @protocol HBHttpOperationDelegate <NSObject>
  30. -(void) cancel;
  31. @end
  32. @interface HBHttpImageDownloaderOperation : NSOperation<HBHttpOperationDelegate>{
  33. BOOL _finished;
  34. BOOL _concurrent;
  35. }
  36. @property (nonatomic,readonly) NSURLRequest * request;
  37. @property (nonatomic,readonly) HBHttpImageDownloaderOption option;
  38. -(id)initWithURL:(NSURL*)url
  39. options:(HBHttpImageDownloaderOption)option
  40. process:(HBHttpImageDownloaderProcessBlock)process
  41. complete:(HBHttpImageDownloaderCompleteBlock)complete
  42. cancel:(void(^)())cancel;
  43. -(void)retry;
  44. @end