瀏覽代碼

1.设置页面的有上传和下载任务时传输列表符号上显示红点

huangxiaodong 1 年之前
父節點
當前提交
9c86be9dda

+ 5 - 0
创维盒子/双子星云手机/AppDelegate/Config/Notification.h

@@ -68,6 +68,8 @@
 #define uploadFileRefreshNotification                 @"uploadFileRefreshNot"
 /* 上传文件暂停通知*/
 #define uploadFileSuspendNotification                 @"uploadFileSuspendNot"
+/* 上传文件通知*/
+#define uploadFileAllTaskDoneNotification                 @"uploadFileAllTaskDoneNot"
 
 /* 上传备份通知*/
 #define backupsFileBeginNotification                 @"backupsFileBeginNot"
@@ -82,6 +84,9 @@
 /*下载文件更新通知*/
 #define downloadFileRefreshNotification                 @"downloadFileRefreshNot"
 
+/* 下载文件通知*/
+#define downloadFileAllTaskDoneNotification                 @"downloadFileAllTaskDoneNot"
+
 /* 创建文件夹通知*/
 #define createFolderBeginNotification                 @"createFolderBeginNot"
 /* 创建文件夹通知*/

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

@@ -37,9 +37,15 @@
 
 @interface MySetViewController ()<HelpDownScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,ComontAlretViewControllerDelegate>
 {
+    UIButton* rightButton;
+    UIView* rightRedView;
+    
     UILabel *phoneLabel;
     UILabel *vipTypeTipsLabel;
     UIButton *tvP2PBtn;
+    
+    BOOL hadUploadTaskType;
+    BOOL hadDownloadTaskType;
 }
 @property (nonatomic, strong, nullable) UITableView *tableView;
 @property (nonatomic, strong, nullable) mySetHeadView *customTableHeadView;
@@ -53,6 +59,10 @@
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneTvStatusFun:)  name:getCouldPhoneTvStatusNotification  object:nil];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileAllTaskDoneNot:)  name:uploadFileAllTaskDoneNotification  object:nil];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileAllTaskDoneNot:)  name:downloadFileAllTaskDoneNotification  object:nil];
+    
     [self drawAnyView];
 }
 
@@ -64,6 +74,8 @@
     if(_getTvStatus){
         _getTvStatus();
     }
+    
+    [self checkFileTransferTask];
 }
 
 - (void)drawAnyView{
@@ -74,7 +86,7 @@
     [self.navBarBGView setHidden:NO];
     [self.titleLabel setText:NSLocalizedString(@"more_set",nil)];
     
-    UIButton* rightButton = [[UIButton alloc] init];
+    rightButton = [[UIButton alloc] init];
     [rightButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
     [rightButton addTarget:self action:@selector(didiClikRightButFun:) forControlEvents:UIControlEventTouchUpInside];
     [self.navBarBGView addSubview:rightButton];
@@ -86,6 +98,19 @@
         make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
     }];
     
+    rightRedView = [[UIView alloc] init];
+    rightRedView.backgroundColor = [UIColor redColor];
+    [rightButton addSubview:rightRedView];
+    rightRedView.layer.cornerRadius = 6;
+    rightRedView.hidden = YES;
+    
+    [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.width.mas_equalTo(12);
+        make.height.mas_equalTo(12);
+        make.right.mas_equalTo(-10);
+        make.top.mas_equalTo(8);
+    }];
+    
     [self.view addSubview:self.tableView];
     [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
@@ -782,4 +807,43 @@
     }
     
 }
+
+- (void)uploadFileAllTaskDoneNot:(NSNotification*)not
+{
+    hadUploadTaskType = NO;
+    [self setRightButtonRedTypeFun];
+}
+
+- (void)downloadFileAllTaskDoneNot:(NSNotification*)not
+{
+    hadDownloadTaskType = NO;
+    [self setRightButtonRedTypeFun];
+}
+
+- (void)checkFileTransferTask
+{
+    KWeakSelf
+    [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
+        self->hadUploadTaskType = isSuccess;
+        [weakSelf setRightButtonRedTypeFun];
+    }];
+    
+    [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
+        self->hadDownloadTaskType = isSuccess;
+        [weakSelf setRightButtonRedTypeFun];
+    }];
+}
+
+- (void)setRightButtonRedTypeFun
+{
+    //mainBlock(^{
+        if(hadUploadTaskType || hadDownloadTaskType){
+            rightRedView.hidden = NO;
+        }
+        else{
+            rightRedView.hidden = YES;
+        }
+
+    //});
+}
 @end

+ 1 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadManager.h

@@ -40,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
 //删除本地数据库记录
 - (void)deleteDownloadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache;
 - (void)checkReDownloadFileFun;
+- (void)checkHadDownloadTaskWithComplete:(custom_complete_B)complete;
 @end
 
 NS_ASSUME_NONNULL_END

+ 28 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/downloadManager.m

@@ -190,6 +190,8 @@ static downloadManager * cur_downloadManager = nil;
     if(_downLoadFileModelDataArr.count == 0)
     {
         _curDownloadFileModel = nil;
+        
+        [self didDownloadAllTaskDoneFun];
         return;
     }
     
@@ -505,4 +507,30 @@ static downloadManager * cur_downloadManager = nil;
     
     [[NSNotificationCenter defaultCenter] postNotificationName:downloadFileBeginNotification object:_curDownloadFileModel];
 }
+
+- (void)didDownloadAllTaskDoneFun
+{
+    [[NSNotificationCenter defaultCenter] postNotificationName:downloadFileAllTaskDoneNotification object:nil];
+}
+
+- (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);
+                }
+            }
+        });
+        
+    }];
+}
 @end

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

@@ -57,6 +57,8 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)deleteUploadFileRecordBy:(NSMutableArray *)delArr withDelCache:(BOOL)isDelCache complete:(custom_complete_B)complete;
 
 - (void)checkReUploadFileFun;
+
+- (void)checkHadUploadTaskWithComplete:(custom_complete_B)complete;
 @end
 
 NS_ASSUME_NONNULL_END

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

@@ -677,6 +677,9 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
         if(self->_fileModelDataArr.count > 0){
             [self beginUploadFileFun];
         }
+        else{
+            [self didUploadAllTaskDoneFun];
+        }
     }];
 }
 
@@ -691,6 +694,7 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
         else{
             self->_isUploadIngType = NO;
             self->_curUploadFileDataModel = nil;
+            [self didUploadAllTaskDoneFun];
         }
     }];
     
@@ -884,6 +888,32 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
         return;
     }
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileBeginNotification object:_curUploadFileDataModel];;
+    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileBeginNotification object:_curUploadFileDataModel];
+}
+
+- (void)checkHadUploadTaskWithComplete:(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);
+                }
+            }
+        });
+        
+    }];
+}
+
+- (void)didUploadAllTaskDoneFun
+{
+    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileAllTaskDoneNotification object:nil];
 }
 @end