Bläddra i källkod

1.上传逻辑处理(1.偶现暂停不了问题 2.全部开启和全部暂停开关)

huangxiaodong 1 år sedan
förälder
incheckning
98a071dd72

+ 18 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileView/uploadFileRecordTableView.m

@@ -325,9 +325,17 @@
 #pragma mark 点击头部右边按钮
 - (void)didClickRightButtonFun:(NSInteger)section
 {
+    if(_uploadingHeadView.rightButton.selected){
+        for (uploadFileDataModel*model in _uploadingArr) {
+            model.curUploadStateType = uploadStateSuspend;
+        }
+    }
+    
     if(_didClickSectionHeadViewRightButton){
         _didClickSectionHeadViewRightButton(section);
     }
+    
+    [self reloadData];
 }
 
 #pragma mark 刷新头部数据
@@ -349,6 +357,16 @@
         }
         else{
             _uploadingHeadView.hidden = NO;
+            
+            BOOL isAllUploadingType = NO;
+            for (uploadFileDataModel*model in _uploadingArr) {
+                if(model.curUploadStateType != uploadStateUploading){
+                    isAllUploadingType = YES;
+                    break;
+                }
+            }
+            
+            _uploadingHeadView.rightButton.selected = isAllUploadingType;
         }
     }
     

+ 1 - 0
创维盒子/双子星云手机/NAS/nasUploadManager/customUploadOperation.h

@@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property(nonatomic,assign) NSInteger  i;//从来控制速度刷新的
 
+@property(nonatomic,assign) BOOL  isCancelType;//是都被点击暂停或者删除了(考虑dataTask取消的情况)
 @end
 
 NS_ASSUME_NONNULL_END

+ 11 - 2
创维盒子/双子星云手机/NAS/nasUploadManager/nasMixUploadManager.m

@@ -52,6 +52,8 @@
 /** 添加要上传的 模型  */
 - (void)addDownloadWithModels:(NSArray *)fileModels{
     
+    HLog(@"添加任务-- %ld",fileModels.count)
+    
     for (uploadFileDataModel *model in fileModels) {
         BOOL needAddType = YES;
         
@@ -354,7 +356,11 @@
 #pragma mark 视频上传
 - (void)beginUploadVideoDataFunBy:(customUploadOperation*)operation with:(NSInteger)position withPara:(NSMutableDictionary*)paraDict success:(netWork_Success)success faild:(netWork_Faild)faildStr
 {
-
+    if(operation.isCancelType){
+        HLog(@"防止取消不了任务生效")
+        return;
+    }
+    
     BOOL isLastPicece = NO;
     if((operation.fileModel.totalBytes - position) <= MaxNasUploadPieceSzie){
         [paraDict setObject:@"true" forKey:@"isLast"];
@@ -762,7 +768,7 @@ didReceiveResponse:(NSURLResponse *)response
 #pragma mark 取消单个任务
 - (void)cancelUploadTaskFunWith:(uploadFileDataModel*)fileModel
 {
-    
+    HLog(@"取消任务-- %@--%@",fileModel.filename,fileModel.taskId)
     @synchronized (self) {
         for (uploadFileDataModel*waitModel in _uploadWaitingUrlArr) {
             if([waitModel.filename isEqualToString:fileModel.filename]){
@@ -773,6 +779,7 @@ didReceiveResponse:(NSURLResponse *)response
         
         for (customUploadOperation*operation in _uploadingOperationArr) {
             if([operation.fileModel.filename isEqualToString:fileModel.filename]){
+                operation.isCancelType = YES;
                 [operation.dataTask cancel];
                 [_uploadingOperationArr removeObject:operation];
                 [self beginUpload];
@@ -786,10 +793,12 @@ didReceiveResponse:(NSURLResponse *)response
 #pragma mark 取消所有任务
 - (void)cancelUploadAllTaskFun
 {
+    HLog(@"取消所有任务")
     @synchronized (self) {
         [_uploadWaitingUrlArr removeAllObjects];
         
         for (customUploadOperation*operation in _uploadingOperationArr) {
+            operation.isCancelType = YES;
             [operation.dataTask cancel];
         }
         

+ 4 - 0
创维盒子/双子星云手机/NAS/nasUploadManager/nasUploadFileManager.m

@@ -620,12 +620,16 @@
     NSMutableArray *uploadingArr = [NSMutableArray new];
     if(!isDeleteAll){
         if(model){
+            model.curUploadStateType = uploadStateSuspend;
             [uploadingArr addObject:model];
         }
     }
     else
     {
         uploadingArr = _databaseArr[0];
+        for (uploadFileDataModel*preModel in uploadingArr) {
+            preModel.curUploadStateType = uploadStateSuspend;
+        }
     }
     
     if(uploadingArr.count > 0){