单军华
2018-07-12 3e8437ae559487362fae3525beb79c534c213a51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
//  ZFDownloadManager.h
//
// Copyright (c) 2016年 任子丰 ( http://github.com/renzifeng )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
 
 
#import <Foundation/Foundation.h>
#import "ZFCommonHelper.h"
#import "ZFDownloadDelegate.h"
#import "ZFFileModel.h"
#import "ZFHttpRequest.h"
 
#define kMaxRequestCount  @"kMaxRequestCount"
 
@interface ZFDownloadManager : NSObject<ZFHttpRequestDelegate>
 
/** 获得下载事件的vc,用在比如多选图片后批量下载的情况,这时需配合 allowNextRequest 协议方法使用 */
@property (nonatomic, weak  ) id<ZFDownloadDelegate> VCdelegate;
/** 下载列表delegate */
@property (nonatomic, weak  ) id<ZFDownloadDelegate> downloadDelegate;
/** 设置最大的并发下载个数 */
@property (nonatomic, assign) NSInteger              maxCount;
/** 已下载完成的文件列表(文件对象) */
@property (atomic, strong, readonly) NSMutableArray  *finishedlist;
/** 正在下载的文件列表(ASIHttpRequest对象) */
@property (atomic, strong, readonly) NSMutableArray  *downinglist;
/** 未下载完成的临时文件数组(文件对象) */
@property (atomic, strong, readonly) NSMutableArray  *filelist;
/** 下载文件的模型 */
@property (nonatomic, strong, readonly) ZFFileModel  *fileInfo;
 
/** 单例 */
+ (ZFDownloadManager *)sharedDownloadManager;
/** 
 * 清除所有正在下载的请求
 */
- (void)clearAllRquests;
/** 
 * 清除所有下载完的文件
 */
- (void)clearAllFinished;
/** 
 * 恢复下载
 */
- (void)resumeRequest:(ZFHttpRequest *)request;
/**
 * 删除这个下载请求
 */
- (void)deleteRequest:(ZFHttpRequest *)request;
/** 
 * 停止这个下载请求
 */
- (void)stopRequest:(ZFHttpRequest *)request;
/** 
 * 保存下载完成的文件信息到plist
 */
- (void)saveFinishedFile;
/** 
 * 删除某一个下载完成的文件
 */
- (void)deleteFinishFile:(ZFFileModel *)selectFile;
/** 
 * 下载视频时候调用
 */
- (void)downFileUrl:(NSString*)url
           filename:(NSString*)name
          fileimage:(UIImage *)image;
/** 
 * 开始任务 
 */
- (void)startLoad;
/** 
 * 全部开始(等于最大下载个数,超过的还是等待下载状态)
 */
- (void)startAllDownloads;
/**
 * 全部暂停 
 */
- (void)pauseAllDownloads;
 
@end