Pārlūkot izejas kodu

1.下载暂停和开启,删除相关处理

huangxiaodong 1 gadu atpakaļ
vecāks
revīzija
6aec175eed

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

@@ -917,7 +917,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

+ 1 - 1
创维盒子/双子星云手机/Class/Set/previewFile/backupsOptionViewController.m

@@ -335,7 +335,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

+ 1 - 1
创维盒子/双子星云手机/Class/Set/previewFile/previewAudioOrDocumentViewController.m

@@ -791,7 +791,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

+ 1 - 1
创维盒子/双子星云手机/Class/Set/previewFile/previewFileAndFolderSecondViewController.m

@@ -624,7 +624,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

+ 1 - 1
创维盒子/双子星云手机/Class/Set/previewFile/previewFileAndFolderViewController.m

@@ -840,7 +840,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

+ 1 - 1
创维盒子/双子星云手机/Class/Set/previewFile/previewImageOrVideoViewController.m

@@ -882,7 +882,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

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

@@ -1154,6 +1154,12 @@
 - (void)downloadFileRefreshFun:(NSNotification*)not
 {
     couldPhoneFileModel *downloadTaskMod = [not object];
+    
+    if(!downloadTaskMod){
+        [_midTableView RefreshAllDataFun];
+        return;
+    }
+    
     HLog(@"hhhhhhh1 %@ didDownloadBytes:%ld",downloadTaskMod.name,downloadTaskMod.didDownloadBytes);
     
     downloadTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
@@ -1247,7 +1253,7 @@
 
 - (void)ClearAllRecordInDownloadDoneFun
 {
-    [[downloadManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
+    [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
 }
 
 
@@ -1276,7 +1282,7 @@
 
 - (void)ClearAllRecordInDownloadFailFun
 {
-    [[downloadManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
+    [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
 }
 
 /**********************************接收相关******************************************/

+ 2 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileView/downloadFileRecordTableView.h

@@ -10,6 +10,8 @@
 #import "downloadManager.h"
 //#import "couldPhoneFileModel.h"
 #import "couldPhoneFileListModel.h"
+#import "nasDownloadFileManager.h"
+
 NS_ASSUME_NONNULL_BEGIN
 
 @interface downloadFileRecordTableView : UITableView

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

@@ -444,7 +444,7 @@
         return;
     }
     
-    [[downloadManager shareInstance] deleteDownloadFileRecordBy:_selectModelArr withDelCache:YES];
+    [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_selectModelArr withDelCache:YES];
     
     [_selectModelArr removeAllObjects];
     //重新拿数据
@@ -463,12 +463,12 @@
 - (void)handleDownloadingStateTapFunBy:(BOOL)isSuspendType with:(couldPhoneFileModel*)model
 {
     if (isSuspendType) {
-        [[downloadManager shareInstance] suspendDownloadFileFun:NO withModel:model];
+        [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:NO withModel:model];
     }
     else{
         NSMutableArray*arr = [NSMutableArray new];
         [arr addObject:model];
-        [[downloadManager shareInstance] reDownloadFileFunBy:arr withAll:NO];
+        [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:arr withAll:NO];
     }
     
     [self reloadDataFun];
@@ -489,7 +489,7 @@
     NSMutableArray*arr = [NSMutableArray new];
     model.curDownloadStateType = downloadStateWait;
     [arr addObject:model];
-    [[downloadManager shareInstance] reDownloadFileFunBy:arr withAll:NO];
+    [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:arr withAll:NO];
     
 }
 @end

+ 1 - 1
创维盒子/双子星云手机/NAS/NASViewController.m

@@ -819,7 +819,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

+ 1 - 1
创维盒子/双子星云手机/NAS/NasPreviewVideoViewController.m

@@ -775,7 +775,7 @@
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
             self->hadDownloadTaskType = isSuccess;
             [weakSelf setRightButtonRedTypeFun];
         }];

+ 5 - 0
创维盒子/双子星云手机/NAS/nasDownloadManager/nasDownloadFileManager.h

@@ -40,6 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 #pragma mark 删除本地数据库记录
 - (void)deleteBoxSaveFileRecordBy:(NSMutableArray *)delArr;
+//删除本地数据库记录
+- (void)deleteDownloadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache;
 
 #pragma mark 更新本地数据库记录
 - (void)updataBoxSaveDataInFailBy:(couldPhoneFileModel*)dataModel;
@@ -54,6 +56,9 @@ NS_ASSUME_NONNULL_BEGIN
 #pragma mark 重新开始下载 第一次进去传输列表是用
 - (void)firstReDownloadAllFileFun;
 
+#pragma mark 检测是否有任务下载中或者暂停
+- (void)checkHadDownloadTaskWithComplete:(custom_complete_B)complete;
+
 #pragma mark-保存完成后 删除此次信息 download done plist
 - (void)deleteDownloadDonePlistInfoBy:(NSString*)fullPath;
 

+ 28 - 0
创维盒子/双子星云手机/NAS/nasDownloadManager/nasDownloadFileManager.m

@@ -286,6 +286,12 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
     
 }
 
+- (void)deleteDownloadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache
+{
+    [self deleteBoxSaveFileRecordBy:delArr];
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName:downloadFileRefreshNotification object:nil];
+}
 
 #pragma mark 更新本地数据库记录
 - (void)updataBoxSaveDataInFailBy:(couldPhoneFileModel*)dataModel
@@ -559,6 +565,28 @@ static nasDownloadFileManager * cur_nasDownloadFileManager = nil;
     }
 }
 
+#pragma mark 检测是否有任务下载中或者暂停
+- (void)checkHadDownloadTaskWithComplete:(custom_complete_B)complete
+{
+    [self getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
+        mainBlock(^{
+            if(!Arr || Arr.count != 3){
+                complete(NO);
+            }
+            else{
+                NSArray *firstArr = Arr[0];
+                if(firstArr.count >0){
+                    complete(YES);
+                }
+                else{
+                    complete(NO);
+                }
+            }
+        });
+        
+    }];
+}
+
 
 #pragma mark- download done plist Path
 - (NSString *)getDownloadDonePlistPath {