瀏覽代碼

1.下载逻辑优化

huangxiaodong 1 年之前
父節點
當前提交
363be13c56

+ 18 - 7
创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/receiveDownloadRecordTableView.m

@@ -31,7 +31,7 @@
         _selectModelArr = [NSMutableArray new];
         _curDataArr = [NSMutableArray new];
         
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:kDownloadTaskFinishedNoti object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskFinishedNotification object:nil];
     }
     return self;
 }
@@ -63,19 +63,29 @@
     
     _outSideDataArr = outSideDataArr;
     
-    _downloadingArr = [NSMutableArray arrayWithArray:outSideDataArr[0]];
+    _downloadingArr = [NSMutableArray new];
+    for (ShareFileDataModel*model in outSideDataArr[0]) {
+        [_downloadingArr addObject:model];
+    }
     
     if(![boxDownloadFileManager shareInstance].isFirstAutoStartType){
         for (ShareFileDataModel*model in _downloadingArr) {
-            model.downloadBoxStateType = downloadBoxStateDownloadloading;
+            if(model.downloadBoxStateType != downloadBoxStateSuspend){
+                model.downloadBoxStateType = downloadBoxStateDownloadloading;
+            }
         }
     }
     
-    _downloadDoneArr = [NSMutableArray arrayWithArray:outSideDataArr[1]];
+    _downloadDoneArr = [NSMutableArray new];
+    for (ShareFileDataModel*model in outSideDataArr[1]) {
+        [_downloadDoneArr addObject:model];
+    }
     
-    //HLog(@"111--%@",_downloadDoneArr);
-    _downloadfailArr = [NSMutableArray arrayWithArray:outSideDataArr[2]];
-    //HLog(@"2222--%@",_downloadfailArr);
+    
+    _downloadfailArr = [NSMutableArray new];
+    for (ShareFileDataModel*model in outSideDataArr[2]) {
+        [_downloadfailArr addObject:model];
+    }
 
     
     [self RefreshAllDataFun];
@@ -199,6 +209,7 @@
             };
 
             cell.didTapPressClick = ^{
+                HLog(@"%@",model);
                 if(model.downloadBoxStateType == downloadBoxStateDownloadloading){
                     model.downloadBoxStateType = downloadBoxStateSuspend;
                     [weakSelf handleDownloadingStateTapFunBy:YES with:model AtIndexPath:indexPath];

+ 11 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/receiveSaveRecordTableView.m

@@ -63,6 +63,17 @@
     _boxSaveDoneArr = [NSMutableArray arrayWithArray:outSideDataArr[1]];
     _boxSavefailArr = [NSMutableArray arrayWithArray:outSideDataArr[2]];
     
+    if(!_boxSaveingArr){
+        _boxSaveingArr = [NSMutableArray new];
+    }
+    
+    if(!_boxSaveDoneArr){
+        _boxSaveDoneArr = [NSMutableArray new];
+    }
+    
+    if(!_boxSavefailArr){
+        _boxSavefailArr = [NSMutableArray new];
+    }
     
     [self RefreshAllDataFun];
 }

+ 14 - 11
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxDownloadFileManager.m

@@ -345,14 +345,14 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
     
     if (item.downloadStatus == YCDownloadStatusFinished) {
         [self handldDownloadDoneDataBy:item];
-        
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-            [[NSNotificationCenter defaultCenter] postNotificationName:nasDownloadTaskFinishedNotification object:item];
-        });
     }
     else if (item.downloadStatus == YCDownloadStatusFailed){
         [self handldDownloadFailDataBy:item];
     }
+    
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [[NSNotificationCenter defaultCenter] postNotificationName:nasDownloadTaskFinishedNotification object:item];
+    });
 }
 
 
@@ -429,9 +429,11 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
                 model.downloadBoxStateType = downloadBoxStateSuspend;
             }
             
-            [ShareFileDataModel bg_updateArrayAsync:downloadingArr complete:^(BOOL isSuccess) {
-                            
-            }];
+            if(downloadingArr.count > 0){
+                [ShareFileDataModel bg_updateArrayAsync:downloadingArr complete:^(BOOL isSuccess) {
+                                
+                }];
+            }
         }
         
         [YCDownloadManager pauseAllDownloadTask];
@@ -475,10 +477,11 @@ static boxDownloadFileManager * cur_boxDownloadFileShareInstance = nil;
                     break;
                 }
             }
-            
-            [ShareFileDataModel bg_updateArrayAsync:downloadingArr complete:^(BOOL isSuccess) {
-                            
-            }];
+            if(downloadingArr.count > 0){
+                [ShareFileDataModel bg_updateArrayAsync:downloadingArr complete:^(BOOL isSuccess) {
+                    
+                }];
+            }
         }
     }
 }