瀏覽代碼

1.上传UI改了一半

huangxiaodong 1 年之前
父節點
當前提交
65d7b5db6f

+ 169 - 65
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileRecordTableView.m

@@ -9,6 +9,7 @@
 #import "uploadFileRecordCell.h"
 #import "UIScrollView+EmptyDataSet.h"
 #import "uploadFileManager.h"
+#import "uploadFileRecordTableViewHeadView.h"
 
 @interface uploadFileRecordTableView()<UITableViewDataSource,UITableViewDelegate,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
 {
@@ -16,6 +17,11 @@
     NSMutableArray *uploadfailArr;
     NSMutableArray *uploadDoneArr;
 }
+
+@property (nonatomic,strong) uploadFileRecordTableViewHeadView *uploadingHeadView;
+@property (nonatomic,strong) uploadFileRecordTableViewHeadView *failHeadView;
+@property (nonatomic,strong) uploadFileRecordTableViewHeadView *doneHeadView;
+
 @property (nonatomic, strong) NSMutableArray *curDataArr;
 @end
 
@@ -56,6 +62,8 @@
         return;
     }
     
+    _outSideDataArr = outSideDataArr;
+    
     uploadingArr = outSideDataArr[0];
     uploadfailArr = outSideDataArr[1];
     uploadDoneArr = outSideDataArr[2];
@@ -115,47 +123,46 @@
         [cell setAccessoryType:(UITableViewCellAccessoryNone)];
     }
     
-    
-    NSMutableArray *curArr = _curDataArr;
-    
-    if(row < curArr.count){
-        uploadFileDataModel *model = curArr[row];
-        cell.curUploadFileDataModel = model;
-        cell.isEditType = _isEditType;
-
-        if(_isEditType){
-            if([_selectModelArr containsObject:model]){
-                cell.isSelectType = YES;
-            }
-            else{
-                cell.isSelectType = NO;
-            }
-        }
+    if(section < _curDataArr.count){
+        NSMutableArray *curArr = _curDataArr[section];
         
-        KWeakSelf
-        cell.didLongPressClick = ^{
-            [weakSelf didLongPressClickFun];
-        };
-
-        cell.didClckSelectBut = ^(BOOL isSelect) {
-            [weakSelf selectModelOneByOne:model BySelect:isSelect];
-        };
-
-        cell.didTapPressClick = ^{
-            if(model.curUploadStateType == uploadStateUploading){
-                [weakSelf handleUploadingStateTapFunBy:YES with:model];
-            }
-            else if(model.curUploadStateType == uploadStateSuspend){
-                [weakSelf handleUploadingStateTapFunBy:NO with:model];
-            }
-            else if(model.curUploadStateType == uploadStateFail){
-                [weakSelf handleUploadFailStateWith:model];
+        if(row < curArr.count){
+            uploadFileDataModel *model = curArr[row];
+            cell.curUploadFileDataModel = model;
+            cell.isEditType = _isEditType;
+
+            if(_isEditType){
+                if([_selectModelArr containsObject:model]){
+                    cell.isSelectType = YES;
+                }
+                else{
+                    cell.isSelectType = NO;
+                }
             }
-        };
+            
+            KWeakSelf
+            cell.didLongPressClick = ^{
+                [weakSelf didLongPressClickFun];
+            };
+
+            cell.didClckSelectBut = ^(BOOL isSelect) {
+                [weakSelf selectModelOneByOne:model BySelect:isSelect];
+            };
+
+            cell.didTapPressClick = ^{
+                if(model.curUploadStateType == uploadStateUploading){
+                    [weakSelf handleUploadingStateTapFunBy:YES with:model];
+                }
+                else if(model.curUploadStateType == uploadStateSuspend){
+                    [weakSelf handleUploadingStateTapFunBy:NO with:model];
+                }
+                else if(model.curUploadStateType == uploadStateFail){
+                    [weakSelf handleUploadFailStateWith:model];
+                }
+            };
+        }
     }
     
-    
-
     return cell;
 }
 
@@ -163,7 +170,81 @@
     return 70;
 }
 
+- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
+{
+    NSInteger curType = 0;// 0 上传中  1 失败 2 完成
+    if(section == 2){
+        curType = 2;
+    }
+    else if(section == 1){
+        if(uploadingArr.count == 0){
+            curType = 2;
+        }
+        else if(uploadfailArr.count == 0){
+            curType = 2;
+        }
+        else{
+            curType = 1;
+        }
+    }
+    else{
+        if(uploadingArr.count > 0){
+            curType = 0;
+        }
+        else if(uploadfailArr.count > 0){
+            curType = 1;
+        }
+        else{
+            curType = 2;
+        }
+    }
+    
+    uploadFileRecordTableViewHeadView *headView = [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
+    //headView.backgroundColor = [UIColor greenColor];
+    
+    headView.didClickButFun = ^{
+            //[weakSelf didClickAllSuspendInLoadingFun];
+    };
+    
+    if(curType == 2){
+        
+        if(_doneHeadView){
+            return _doneHeadView;
+        }
+        else{
+            _doneHeadView = headView;
+        }
+        
+    }
+    else if(curType == 1){
+        
+        if(_failHeadView){
+            return _failHeadView;
+        }
+        else{
+            _failHeadView = headView;
+        }
+        
+    }
+    else{
+        if(_uploadingHeadView){
+            return _uploadingHeadView;
+        }
+        else{
+            _uploadingHeadView = headView;
+        }
+        
+    }
+    
+    [self RefresHeadUIFun];
+    
+    return headView;
+}
 
+- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
+{
+    return 40;
+}
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
     
@@ -215,47 +296,70 @@
 #pragma mark 熟悉头部数据
 -(void)RefresHeadUIFun
 {
-    uploadFileRecordTableViewHeadView *headView = (uploadFileRecordTableViewHeadView *)self.tableHeaderView;
-    
-    if(!headView || ![headView isKindOfClass:[uploadFileRecordTableViewHeadView class]]){
-        return;
-    }
-    
-    if(!_curDataArr ||_curDataArr.count ==0){
-        headView.hidden = YES;
-        return;
-    }
-   
-    headView.hidden = NO;
-
-    NSInteger tag = self.tag;
+//    uploadFileRecordTableViewHeadView *headView = (uploadFileRecordTableViewHeadView *)self.tableHeaderView;
+//
+//    if(!headView || ![headView isKindOfClass:[uploadFileRecordTableViewHeadView class]]){
+//        return;
+//    }
+//
+//    if(!_curDataArr ||_curDataArr.count ==0){
+//        headView.hidden = YES;
+//        return;
+//    }
+//
+//    headView.hidden = NO;
+//
+//    NSInteger tag = self.tag;
     
-    if(tag == 100){
+    if(_uploadingHeadView){
         NSString *leftStr =  NSLocalizedString(@"File_upload_Record_uploading",nil);
         NSString *rightStr =  NSLocalizedString(@"File_upload_Record_all_suspend",nil);
         NSString *rightSelectStr =  NSLocalizedString(@"File_upload_Record_all_open",nil);
-        NSString *titleStr = [[NSString alloc] initWithFormat:@"%@ (%ld)",leftStr,_curDataArr.count];
+        NSString *titleStr = [[NSString alloc] initWithFormat:@"%@ (%ld)",leftStr,uploadingArr.count];
 
-        headView.titleLabel.text = titleStr;
-        [headView.rightButton setTitle:rightStr forState:UIControlStateNormal];
-        [headView.rightButton setTitle:rightSelectStr forState:UIControlStateSelected];
+        _uploadingHeadView.titleLabel.text = titleStr;
+        [_uploadingHeadView.rightButton setTitle:rightStr forState:UIControlStateNormal];
+        [_uploadingHeadView.rightButton setTitle:rightSelectStr forState:UIControlStateSelected];
         
+        if(uploadingArr.count == 0){
+            _uploadingHeadView.hidden = YES;
+        }
+        else{
+            _uploadingHeadView.hidden = NO;
+        }
     }
-    else if(tag == 101){
+    
+        
+     if(_failHeadView){
         NSString *leftStr =  NSLocalizedString(@"File_upload_Record_did_upload",nil);
         NSString *rightStr =  NSLocalizedString(@"File_upload_Record_clear_Record",nil);
-        NSString *titleStr = [[NSString alloc] initWithFormat:@"%@ (%ld)",leftStr,_curDataArr.count];
-
-        headView.titleLabel.text = titleStr;
-        [headView.rightButton setTitle:rightStr forState:UIControlStateNormal];
+        NSString *titleStr = [[NSString alloc] initWithFormat:@"%@ (%ld)",leftStr,uploadfailArr.count];
+
+         _failHeadView.titleLabel.text = titleStr;
+        [_failHeadView.rightButton setTitle:rightStr forState:UIControlStateNormal];
+         
+         if(uploadfailArr.count == 0){
+             _failHeadView.hidden = YES;
+         }
+         else{
+             _failHeadView.hidden = NO;
+         }
     }
-    else if(tag == 102){
+    
+    if(_doneHeadView){
         NSString *leftStr =  NSLocalizedString(@"File_upload_Record_did_upload",nil);
         NSString *rightStr =  NSLocalizedString(@"File_upload_Record_clear_Record",nil);
-        NSString *titleStr = [[NSString alloc] initWithFormat:@"%@ (%ld)",leftStr,_curDataArr.count];
+        NSString *titleStr = [[NSString alloc] initWithFormat:@"%@ (%ld)",leftStr,uploadDoneArr.count];
 
-        headView.titleLabel.text = titleStr;
-        [headView.rightButton setTitle:rightStr forState:UIControlStateNormal];
+        _doneHeadView.titleLabel.text = titleStr;
+        [_doneHeadView.rightButton setTitle:rightStr forState:UIControlStateNormal];
+        
+        if(uploadDoneArr.count == 0){
+            _doneHeadView.hidden = YES;
+        }
+        else{
+            _doneHeadView.hidden = NO;
+        }
     }
 }
 

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

@@ -32,8 +32,8 @@
 @property (nonatomic, strong) uploadFileRecordTableView *midTableView;
 @property (nonatomic, strong) backupsFilerecordTableView *rightTableView;
 
-@property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView;
-@property (nonatomic,strong) uploadFileRecordTableViewHeadView *midHeadView;
+//@property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView;
+//@property (nonatomic,strong) uploadFileRecordTableViewHeadView *midHeadView;
 
 
 //@property (nonatomic, strong) NSMutableArray *allDataArr;
@@ -168,17 +168,17 @@
     
     _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*3.0, curHeight);
     
-    _leftHeadView =  [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
-    _leftTableView.tableHeaderView = _leftHeadView;
-    _leftHeadView.didClickButFun = ^{
-        [weakSelf didClickAllSuspendInLoadingFun];
-    };
-    
-    _midHeadView =  [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
-    _midTableView.tableHeaderView = _midHeadView;
-    _midHeadView.didClickButFun = ^{
-        [weakSelf didClickClearRecordInDoneFun];
-    };
+//    _leftHeadView =  [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
+//    _leftTableView.tableHeaderView = _leftHeadView;
+//    _leftHeadView.didClickButFun = ^{
+//        [weakSelf didClickAllSuspendInLoadingFun];
+//    };
+//
+//    _midHeadView =  [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
+//    _midTableView.tableHeaderView = _midHeadView;
+//    _midHeadView.didClickButFun = ^{
+//        [weakSelf didClickClearRecordInDoneFun];
+//    };
     
 
 
@@ -576,7 +576,7 @@
 //
 //        }
 //    }
-    
+//    
 }
 
 - (void)uploadFileDeteleFun:(NSNotification*)not
@@ -585,34 +585,34 @@
     //HLog(@"%@",uploadFileDataMod);
     
     //UI和数据还没准备好
-//    if(!_leftTableView){
-//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-//            [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:uploadFileDataMod];
-//        });
-//
-//        return;
-//    }
-//
-//    if([uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
-//
-//        NSMutableArray *curArr = _leftTableView.curDataArr;
-//
-//        NSInteger index = 0;
-//        for (uploadFileDataModel*mod in curArr) {
-//            HLog(@"bg_id:%@ ?=? %@",mod.bg_id,uploadFileDataMod.bg_id);
-//
-//            if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
-//                [curArr removeObject:mod];
-//                break;
-//            }
-//
-//            index++;
-//        }
-//
-//        //精准刷新
-//        //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
-//        [self.leftTableView reloadDataFun];
-//    }
+    if(!_leftTableView.outSideDataArr || _leftTableView.outSideDataArr.count !=3){
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:uploadFileDataMod];
+        });
+
+        return;
+    }
+
+    if([uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
+
+        NSMutableArray *curArr = _leftTableView.outSideDataArr[0];
+
+        NSInteger index = 0;
+        for (uploadFileDataModel*mod in curArr) {
+            HLog(@"bg_id:%@ ?=? %@",mod.bg_id,uploadFileDataMod.bg_id);
+
+            if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
+                [curArr removeObject:mod];
+                break;
+            }
+
+            index++;
+        }
+
+        //精准刷新
+        //[self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
+        [self.leftTableView reloadDataFun];
+    }
     
 }
 
@@ -664,7 +664,7 @@
     _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
     _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
     
-    _leftHeadView.rightButton.userInteractionEnabled = !isEditType;
+    //_leftHeadView.rightButton.userInteractionEnabled = !isEditType;
     
     if(_isEditType){
        
@@ -736,7 +736,7 @@
 #pragma mark 点击上传中的全部暂停
 - (void)didClickAllSuspendInLoadingFun
 {
-    _leftHeadView.rightButton.selected = !_leftHeadView.rightButton.selected;
+   // _leftHeadView.rightButton.selected = !_leftHeadView.rightButton.selected;
     
 //    if(_leftHeadView.rightButton.selected){
 //        [[uploadFileManager shareInstance] suspendUploadFileFun:YES];