|
@@ -390,23 +390,42 @@ static downloadManager * cur_downloadManager = nil;
|
|
|
[lock unlock];
|
|
|
}
|
|
|
|
|
|
-- (void)suspendDownloadFileFun:(BOOL)isSuspendAll
|
|
|
+- (void)suspendDownloadFileFun:(BOOL)isSuspendAll withModel:(couldPhoneFileModel*)model
|
|
|
{
|
|
|
- _isSuspendType = YES;
|
|
|
|
|
|
if(isSuspendAll){
|
|
|
- for (couldPhoneFileModel *couldPhoneFileMod in _downLoadFileModelDataArr) {
|
|
|
- couldPhoneFileMod.curDownloadStateType = downloadStateSuspend;
|
|
|
- }
|
|
|
- [_downLoadFileModelDataArr removeAllObjects];
|
|
|
-
|
|
|
+ _isSuspendType = YES;
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:downloadFileSuspendAllNotification object:nil];
|
|
|
+
|
|
|
+// for (couldPhoneFileModel *couldPhoneFileMod in _downLoadFileModelDataArr) {
|
|
|
+// couldPhoneFileMod.curDownloadStateType = downloadStateSuspend;
|
|
|
+// }
|
|
|
+
|
|
|
+ [self changeDownloadState:downloadStateSuspend withModelArr:_downLoadFileModelDataArr complete:^(BOOL isSuccess) {
|
|
|
+ [self->_downLoadFileModelDataArr removeAllObjects];
|
|
|
+ }];
|
|
|
+
|
|
|
}
|
|
|
else{
|
|
|
- [_downLoadFileModelDataArr removeObject:_curDownloadFileModel];
|
|
|
|
|
|
- _reDownloadIngSelectIndex = -1;
|
|
|
- [self beginDownloadFileFun];
|
|
|
+ couldPhoneFileModel *curModel = _curDownloadFileModel;
|
|
|
+ if(model){
|
|
|
+ curModel = model;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ _isSuspendType = YES;
|
|
|
+ }
|
|
|
+
|
|
|
+ [self changeDownloadState:downloadStateSuspend withModelArr:@[curModel] complete:^(BOOL isSuccess) {
|
|
|
+ [self->_downLoadFileModelDataArr removeObject:model];
|
|
|
+
|
|
|
+ if(curModel.bg_id.integerValue == self->_curDownloadFileModel.bg_id.integerValue){
|
|
|
+ //开启下一个任务
|
|
|
+ _reDownloadIngSelectIndex = -1;
|
|
|
+ [self beginDownloadFileFun];
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -421,49 +440,23 @@ static downloadManager * cur_downloadManager = nil;
|
|
|
_isNewAddTaskType = YES;
|
|
|
_downLoadFileModelDataArr = [NSMutableArray arrayWithArray:Arr];
|
|
|
_reDownloadIngSelectIndex = -1;
|
|
|
- [self beginDownloadFileFun];
|
|
|
- return;
|
|
|
+
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ _isNewAddTaskType = NO;
|
|
|
+ _reDownloadIngSelectIndex = 0;
|
|
|
+
|
|
|
+ NSMutableArray *curArr = [NSMutableArray arrayWithArray:Arr];
|
|
|
+
|
|
|
+ for (uploadFileDataModel*addModel in curArr){
|
|
|
+ [_downLoadFileModelDataArr insertObject:addModel atIndex:0];
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- _isNewAddTaskType = NO;
|
|
|
- _reDownloadIngSelectIndex = 0;
|
|
|
-
|
|
|
- NSMutableArray *curArr = [NSMutableArray arrayWithArray:Arr];
|
|
|
- //_downLoadFileModelDataArr = curArr;
|
|
|
- for (uploadFileDataModel*addModel in curArr){
|
|
|
- [_downLoadFileModelDataArr insertObject:addModel atIndex:0];
|
|
|
- [self beginDownloadFileFun];
|
|
|
- }
|
|
|
-
|
|
|
-// for (uploadFileDataModel*addModel in Arr) {
|
|
|
-//
|
|
|
-// BOOL needAddModel = YES;
|
|
|
-//
|
|
|
-// for (int i=0;i< _downLoadFileModelDataArr.count;i++)
|
|
|
-// {
|
|
|
-// couldPhoneFileModel*preModel = _downLoadFileModelDataArr[i];
|
|
|
-//
|
|
|
-// if(addModel.bg_id.integerValue == preModel.bg_id.integerValue)
|
|
|
-// {
|
|
|
-// needAddModel = NO;
|
|
|
-//
|
|
|
-// if(_reDownloadIngSelectIndex == 0){
|
|
|
-// _reDownloadIngSelectIndex = i;
|
|
|
-//
|
|
|
-// if(i==0){
|
|
|
-// _reDownloadIngSelectIndex = -1;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(needAddModel){
|
|
|
-// [_downLoadFileModelDataArr addObject:addModel];
|
|
|
-// _reDownloadIngSelectIndex = _downLoadFileModelDataArr.count -1;
|
|
|
-// }
|
|
|
-// }
|
|
|
+ [self changeDownloadState:downloadStateUploading withModelArr:_downLoadFileModelDataArr complete:^(BOOL isSuccess) {
|
|
|
+
|
|
|
+ }];
|
|
|
|
|
|
[self beginDownloadFileFun];
|
|
|
}
|
|
@@ -513,7 +506,7 @@ static downloadManager * cur_downloadManager = nil;
|
|
|
|
|
|
if(couldPhoneFileMod.bg_id.integerValue == _curDownloadFileModel.bg_id.integerValue){
|
|
|
isDelUploadingModel = YES;
|
|
|
- [self suspendDownloadFileFun:NO];
|
|
|
+ [self suspendDownloadFileFun:NO withModel:_curDownloadFileModel];
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -529,6 +522,20 @@ static downloadManager * cur_downloadManager = nil;
|
|
|
|
|
|
}
|
|
|
|
|
|
+//修改文件上传的状态
|
|
|
+- (void)changeDownloadState:(downloadStateType)curDownloadStateType withModelArr:(NSArray*)modelArr complete:(custom_complete_B)complete
|
|
|
+{
|
|
|
+
|
|
|
+ for (couldPhoneFileModel * model in modelArr) {
|
|
|
+ model.curDownloadStateType = curDownloadStateType;
|
|
|
+ }
|
|
|
+
|
|
|
+ [couldPhoneFileModel bg_saveOrUpdateArrayAsync:modelArr complete:^(BOOL isSuccess) {
|
|
|
+ complete(YES);
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
//检查是否需要重新下载
|
|
|
- (void)checkReDownloadFileFun
|
|
|
{
|