Просмотр исходного кода

1.缩略图下载还原之前的逻辑--添加任务发送就删除 防止任务失败卡主的情况

huangxiaodong 1 год назад
Родитель
Сommit
e0d955c759

+ 3 - 3
创维盒子/双子星云手机/Class/Set/uploadFile/downLoadFile/downLoadPreviewViewController.m

@@ -613,9 +613,9 @@
 #pragma mark 去下载缩略图
 - (void)gotoDownThumbnailManagerFun
 {
-//    if(_curCouldPhoneFileListMod.data.list && _curCouldPhoneFileListMod.data.list.count >0){
-//        [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailWith:_curCouldPhoneFileListMod.data.list];
-//    }
+    if(_curCouldPhoneFileListMod.data.list && _curCouldPhoneFileListMod.data.list.count >0){
+        [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailWith:_curCouldPhoneFileListMod.data.list];
+    }
 }
 
 - (void)gotoDownloadloadFileRecordFun

+ 1 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/downLoadFile/view/downLoadPreViewCell.m

@@ -138,7 +138,7 @@
 {
     _curFileModel = curFileModel;
     
-    [[downloadThumbnailManager shareInstance] handlToDownloadOneThumbnailWith:_curFileModel];
+    //[[downloadThumbnailManager shareInstance] handlToDownloadOneThumbnailWith:_curFileModel];
     
     mImageView.image = [UIImage imageNamed:@"uploadFile_image"];
     if([curFileModel.fileType isEqualToString:@"video"])

+ 4 - 4
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadThumbnailManager.h

@@ -23,13 +23,13 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property(nonatomic,assign) BOOL  isPreViewTask;//预览进来的任务
 
-//- (void)handlToDownloadThumbnailWith:(NSArray*)Arr;
-//- (void)handlToDownloadThumbnailInDownTableViewWith:(NSArray*)Arr;
+- (void)handlToDownloadThumbnailWith:(NSArray*)Arr;
+- (void)handlToDownloadThumbnailInDownTableViewWith:(NSArray*)Arr;
 - (void)DownloadFileDoneOneFileFun;
 
-//- (void)checkReDownloadThumbnailFileFun;
+- (void)checkReDownloadThumbnailFileFun;
 
-- (void)handlToDownloadOneThumbnailWith:(couldPhoneFileModel*)model;
+//- (void)handlToDownloadOneThumbnailWith:(couldPhoneFileModel*)model;
 @end
 
 NS_ASSUME_NONNULL_END

+ 83 - 80
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadThumbnailManager.m

@@ -37,71 +37,73 @@ static downloadThumbnailManager * cur_downloadFileShareInstance = nil;
     return self;
 }
 
-//- (void)handlToDownloadThumbnailWith:(NSArray*)Arr
-//{
-//    _isPreViewTask = YES;
-//    [self handDataArrFun:Arr];
-//}
+- (void)handlToDownloadThumbnailWith:(NSArray*)Arr
+{
+    _isPreViewTask = YES;
+    [self handDataArrFun:Arr];
+}
 
-//- (void)handDataArrFun:(NSArray*)Arr{
-//    if(Arr && Arr.count >0){
-//        NSLock *lock = [NSLock new];
-//        [lock lock];
-//        if (!_waitDownloadTaskArr) {
-//            _waitDownloadTaskArr = [NSMutableArray arrayWithArray:Arr];
-//        }
-//        else{
-//            [_waitDownloadTaskArr addObjectsFromArray:Arr];
-//        }
-//        
-//        [self planToDownloadThumbnailFun];
-//        [lock unlock];
-//    }
-//}
+- (void)handDataArrFun:(NSArray*)Arr{
+    if(Arr && Arr.count >0){
+        NSLock *lock = [NSLock new];
+        [lock lock];
+        if (!_waitDownloadTaskArr) {
+            _waitDownloadTaskArr = [NSMutableArray arrayWithArray:Arr];
+        }
+        else{
+            [_waitDownloadTaskArr addObjectsFromArray:Arr];
+        }
+        
+        [self planToDownloadThumbnailFun];
+        [lock unlock];
+    }
+}
 
-//- (void)handlToDownloadThumbnailInDownTableViewWith:(NSArray*)Arr{
-//    if(_isPreViewTask){
-//        if (_downloadingTaskArr.count == 0 ) {
-//            [self handDataArrFun:Arr];
-//        }
-//        else{
-//            //不处理
-//        }
-//    }
-//    else{
-//        [self handDataArrFun:Arr];
-//    }
-//}
+- (void)handlToDownloadThumbnailInDownTableViewWith:(NSArray*)Arr{
+    if(_isPreViewTask){
+        if (_downloadingTaskArr.count == 0 ) {
+            [self handDataArrFun:Arr];
+        }
+        else{
+            //不处理
+        }
+    }
+    else{
+        [self handDataArrFun:Arr];
+    }
+}
 
-//- (void)planToDownloadThumbnailFun
+- (void)planToDownloadThumbnailFun
+{
+    if (!_downloadingTaskArr || _downloadingTaskArr.count == 0) {
+        _downloadingTaskArr = [NSMutableArray arrayWithArray:_waitDownloadTaskArr];
+        [_waitDownloadTaskArr removeAllObjects];
+    }
+    
+    [self beginDownloadThumbnailFun];
+}
+
+//- (void)handlToDownloadOneThumbnailWith:(couldPhoneFileModel*)model
 //{
-//    if (!_downloadingTaskArr || _downloadingTaskArr.count == 0) {
-//        _downloadingTaskArr = [NSMutableArray arrayWithArray:_waitDownloadTaskArr];
-//        [_waitDownloadTaskArr removeAllObjects];
-//    }
-//    
-//    [self beginDownloadThumbnailFun];
+//    [self beginDownloadThumbnailFun:model];
 //}
 
-- (void)handlToDownloadOneThumbnailWith:(couldPhoneFileModel*)model
-{
-    [self beginDownloadThumbnailFun:model];
-}
+//- (void)beginDownloadThumbnailFun:(couldPhoneFileModel*)model
+//{
+//    self.curDownloadFileModel = model;
 
-- (void)beginDownloadThumbnailFun:(couldPhoneFileModel*)model
-{
-    self.curDownloadFileModel = model;
-//    if (_downloadingTaskArr.count > 0) {
-//        _curDownloadFileModel = _downloadingTaskArr.firstObject;
-//    }
-//    else{
-//        if(_waitDownloadTaskArr && _waitDownloadTaskArr.count>0){
-//            _downloadingTaskArr = [NSMutableArray arrayWithArray:_waitDownloadTaskArr];
-//            [_waitDownloadTaskArr removeAllObjects];
-//            [self beginDownloadThumbnailFun];
-//        }
-//        return;
-//    }
+- (void)beginDownloadThumbnailFun{
+    if (_downloadingTaskArr.count > 0) {
+        _curDownloadFileModel = _downloadingTaskArr.firstObject;
+    }
+    else{
+        if(_waitDownloadTaskArr && _waitDownloadTaskArr.count>0){
+            _downloadingTaskArr = [NSMutableArray arrayWithArray:_waitDownloadTaskArr];
+            [_waitDownloadTaskArr removeAllObjects];
+            [self beginDownloadThumbnailFun];
+        }
+        return;
+    }
     
     //检测本地是否已经下载文件了
     NSString *fileName = [self.curDownloadFileModel getFileNameFun];
@@ -112,38 +114,39 @@ static downloadThumbnailManager * cur_downloadFileShareInstance = nil;
         //已经下载过了
         [_downloadingTaskArr removeObject:_curDownloadFileModel];
         _curDownloadFileModel = nil;
-        //[self beginDownloadThumbnailFun];
+        [self beginDownloadThumbnailFun];
         return;
     }
     
     self.taskRenewTime = [iTools getNowTimeStamp];
     [[NSNotificationCenter defaultCenter] postNotificationName:downloadThumbnailBeginNotification object:_curDownloadFileModel];
+    [_downloadingTaskArr removeObject:_curDownloadFileModel];
 }
 
 - (void)DownloadFileDoneOneFileFun
 {
-//    [_downloadingTaskArr removeObject:_curDownloadFileModel];
-//    _curDownloadFileModel = nil;
-//    [self beginDownloadThumbnailFun];
-//    self.taskRenewTime = [iTools getNowTimeStamp];
     [[NSNotificationCenter defaultCenter] postNotificationName:downloadThumbnailDoneOneNotification object:nil];
+    
+    _curDownloadFileModel = nil;
+    [self beginDownloadThumbnailFun];
+    self.taskRenewTime = [iTools getNowTimeStamp];
 }
 
-//- (void)checkReDownloadThumbnailFileFun
-//{
-//    NSInteger curTime = [iTools getNowTimeStamp];
-//    
-//    if(self.taskRenewTime == 0){
-//        return;
-//    }
-//    
-//    if(curTime - self.taskRenewTime < 10){
-//        return;
-//    }
-//    
-//    if((_downloadingTaskArr && _downloadingTaskArr.count >0)
-//       ||(_waitDownloadTaskArr && _waitDownloadTaskArr.count>0)){
-//        [self beginDownloadThumbnailFun];
-//    }
-//}
+- (void)checkReDownloadThumbnailFileFun
+{
+    NSInteger curTime = [iTools getNowTimeStamp];
+    
+    if(self.taskRenewTime == 0){
+        return;
+    }
+    
+    if(curTime - self.taskRenewTime < 10){
+        return;
+    }
+    
+    if((_downloadingTaskArr && _downloadingTaskArr.count >0)
+       ||(_waitDownloadTaskArr && _waitDownloadTaskArr.count>0)){
+        [self beginDownloadThumbnailFun];
+    }
+}
 @end

+ 9 - 9
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileRecordViewController.m

@@ -543,15 +543,15 @@
         });
         
         //检测下预览图片是否都下载
-//        if(isRegetType){
-//            if(Arr &&Arr.count == 3){
-//                NSArray *downingArr = Arr[0];
-//                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-//                    [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailInDownTableViewWith:downingArr];
-//                });
-//            }
-//            
-//        }
+        if(isRegetType){
+            if(Arr &&Arr.count == 3){
+                NSArray *downingArr = Arr[0];
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                    [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailInDownTableViewWith:downingArr];
+                });
+            }
+            
+        }
         
     }];
     

+ 1 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileView/downloadFileRecordCell.m

@@ -220,7 +220,7 @@
     
     _curCouldPhoneFileModel = curCouldPhoneFileModel;
     
-    [[downloadThumbnailManager shareInstance] handlToDownloadOneThumbnailWith:_curCouldPhoneFileModel];
+    //[[downloadThumbnailManager shareInstance] handlToDownloadOneThumbnailWith:_curCouldPhoneFileModel];
     
     if(_curCouldPhoneFileModel.curDownloadStateType != downloadStateDone){
         //HLog(@"hhhhhhh2  %@ %ld ",_curCouldPhoneFileModel.name,_curCouldPhoneFileModel.didDownloadBytes);

+ 1 - 1
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.mm

@@ -445,7 +445,7 @@
     [[uploadFileManager shareInstance] checkReUploadFileFun];
     [[downloadManager shareInstance] checkReDownloadFileFun];
     
-    //[[downloadThumbnailManager shareInstance] checkReDownloadThumbnailFileFun];
+    [[downloadThumbnailManager shareInstance] checkReDownloadThumbnailFileFun];
     
     [self checkCommandSendTaskFun];