|
@@ -13,12 +13,10 @@
|
|
|
|
|
|
@interface backupsFilerecordTableView()<UITableViewDataSource,UITableViewDelegate,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
|
|
|
{
|
|
|
- NSMutableArray *backupsingArr;
|
|
|
- NSMutableArray *backupsfailArr;
|
|
|
- NSMutableArray *backupsDoneArr;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-@property (nonatomic, strong) NSMutableArray *curDataArr;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation backupsFilerecordTableView
|
|
@@ -27,12 +25,7 @@
|
|
|
self = [super initWithFrame:frame];
|
|
|
if (self) {
|
|
|
[self initCommon];
|
|
|
- _selectModelArr = [NSMutableArray new];
|
|
|
- _curDataArr = [NSMutableArray new];
|
|
|
-
|
|
|
- backupsingArr = [NSMutableArray new];
|
|
|
- backupsfailArr = [NSMutableArray new];
|
|
|
- backupsDoneArr = [NSMutableArray new];
|
|
|
+
|
|
|
}
|
|
|
return self;
|
|
|
}
|
|
@@ -60,106 +53,37 @@
|
|
|
- (void)setPhotosBackupsIngTaskModel:(photosBackupsTaskModel *)photosBackupsIngTaskModel
|
|
|
{
|
|
|
_photosBackupsIngTaskModel = photosBackupsIngTaskModel;
|
|
|
-
|
|
|
-// if(_photosBackupsIngTaskModel.curBackupsState == backupsStateDone){
|
|
|
-// NSInteger i;
|
|
|
-// }
|
|
|
-
|
|
|
- if(backupsingArr.count >=1){
|
|
|
-
|
|
|
- if(_photosBackupsIngTaskModel.curBackupsState == backupsStateUploading
|
|
|
- || _photosBackupsIngTaskModel.curBackupsState == backupsStateSuspend){
|
|
|
- [backupsingArr replaceObjectAtIndex:0 withObject:_photosBackupsIngTaskModel];
|
|
|
- }
|
|
|
- else if (_photosBackupsIngTaskModel.curBackupsState == backupsStateFail){
|
|
|
- [backupsingArr removeObjectAtIndex:0];
|
|
|
- [backupsfailArr insertObject:_photosBackupsIngTaskModel atIndex:0];
|
|
|
- }
|
|
|
- else if (_photosBackupsIngTaskModel.curBackupsState == backupsStateDone){
|
|
|
- [backupsingArr removeObjectAtIndex:0];
|
|
|
- [backupsDoneArr insertObject:_photosBackupsIngTaskModel atIndex:0];
|
|
|
- }
|
|
|
- }
|
|
|
- else if(_photosBackupsIngTaskModel.curBackupsState == backupsStateUploading)
|
|
|
- {//先进界面 再备份
|
|
|
- [backupsingArr addObject:_photosBackupsIngTaskModel];
|
|
|
- }
|
|
|
-
|
|
|
- NSMutableArray*newDataArr = [NSMutableArray new];
|
|
|
- if(backupsingArr.count > 0){
|
|
|
- [newDataArr addObject:backupsingArr];
|
|
|
- }
|
|
|
-
|
|
|
- if(backupsfailArr.count > 0){
|
|
|
- [newDataArr addObject:backupsfailArr];
|
|
|
- }
|
|
|
-
|
|
|
- if(backupsDoneArr.count > 0){
|
|
|
- [newDataArr addObject:backupsDoneArr];
|
|
|
- }
|
|
|
-
|
|
|
- _curDataArr = newDataArr;
|
|
|
+ NSArray *curArr = @[_photosBackupsIngTaskModel];
|
|
|
+ _curDataArr = curArr;
|
|
|
[self reloadDataFun];
|
|
|
}
|
|
|
|
|
|
--(void)setOutSideDataArr:(NSArray *)outSideDataArr
|
|
|
+- (void)setCurDataArr:(NSArray *)curDataArr
|
|
|
{
|
|
|
- _outSideDataArr = outSideDataArr;
|
|
|
-
|
|
|
- [backupsingArr removeAllObjects];
|
|
|
- [backupsfailArr removeAllObjects];
|
|
|
- [backupsDoneArr removeAllObjects];
|
|
|
-
|
|
|
- if(outSideDataArr && outSideDataArr.count >0){
|
|
|
- for (photosBackupsTaskModel*model in outSideDataArr) {
|
|
|
- if(model.curBackupsState == backupsStateUploading
|
|
|
- ||model.curBackupsState == backupsStateSuspend){
|
|
|
- [backupsingArr addObject:model];
|
|
|
- }
|
|
|
- else if(model.curBackupsState == backupsStateFail){
|
|
|
- [backupsfailArr addObject:model];
|
|
|
- }
|
|
|
- else{
|
|
|
- [backupsDoneArr addObject:model];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(backupsingArr.count > 0){
|
|
|
- [_curDataArr addObject:backupsingArr];
|
|
|
- }
|
|
|
-
|
|
|
- if(backupsfailArr.count > 0){
|
|
|
- [_curDataArr addObject:backupsfailArr];
|
|
|
- }
|
|
|
-
|
|
|
- if(backupsDoneArr.count > 0){
|
|
|
- [_curDataArr addObject:backupsDoneArr];
|
|
|
- }
|
|
|
-
|
|
|
+ _curDataArr = curDataArr;
|
|
|
[self reloadDataFun];
|
|
|
}
|
|
|
|
|
|
#pragma mark - 列表委托
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
|
- return _curDataArr.count;
|
|
|
+ return 1;//_curDataArr.count;
|
|
|
}
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
|
|
- if(_curDataArr.count > section){
|
|
|
- NSArray *curArr = _curDataArr[section];
|
|
|
- return curArr.count;
|
|
|
- }
|
|
|
+// if(_curDataArr.count > section){
|
|
|
+// NSArray *curArr = _curDataArr[section];
|
|
|
+// return curArr.count;
|
|
|
+// }
|
|
|
|
|
|
- return 0;
|
|
|
+ return _curDataArr.count;
|
|
|
|
|
|
}
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
|
|
NSInteger row = indexPath.row;
|
|
|
- NSInteger section = indexPath.section;
|
|
|
+ //NSInteger section = indexPath.section;
|
|
|
static NSString *identifier = @"backupsFileRecordCell";
|
|
|
|
|
|
backupsFileRecordCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
|
@@ -171,45 +95,31 @@
|
|
|
[cell setAccessoryType:(UITableViewCellAccessoryNone)];
|
|
|
}
|
|
|
|
|
|
- if(section <_curDataArr.count){
|
|
|
- NSMutableArray *curArr = _curDataArr[section];
|
|
|
-
|
|
|
- if(row < curArr.count){
|
|
|
- photosBackupsTaskModel *model = curArr[row];
|
|
|
- cell.curPhotosBackupsTaskModel = model;
|
|
|
- //cell.isEditType = _isEditType;
|
|
|
+ if(row < _curDataArr.count){
|
|
|
+ photosBackupsTaskModel *model = _curDataArr[row];
|
|
|
+ cell.curPhotosBackupsTaskModel = model;
|
|
|
|
|
|
- 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.curBackupsState == backupsStateUploading){
|
|
|
+ [weakSelf handleBackupsingStateTapFunBy:YES with:model];
|
|
|
+ }
|
|
|
+ else if(model.curBackupsState == backupsStateSuspend){
|
|
|
+ [weakSelf handleBackupsingStateTapFunBy:NO with:model];
|
|
|
}
|
|
|
|
|
|
- KWeakSelf
|
|
|
- cell.didLongPressClick = ^{
|
|
|
- //[weakSelf didLongPressClickFun];
|
|
|
- };
|
|
|
-
|
|
|
- cell.didClckSelectBut = ^(BOOL isSelect) {
|
|
|
- //[weakSelf selectModelOneByOne:model BySelect:isSelect];
|
|
|
- };
|
|
|
-
|
|
|
- cell.didTapPressClick = ^{
|
|
|
- if(model.curBackupsState == backupsStateUploading){
|
|
|
- [weakSelf handleBackupsingStateTapFunBy:YES with:model];
|
|
|
- }
|
|
|
- else if(model.curBackupsState == backupsStateSuspend){
|
|
|
- [weakSelf handleBackupsingStateTapFunBy:NO with:model];
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
+ };
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
@@ -227,45 +137,25 @@
|
|
|
titleLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
|
|
|
[headView addSubview:titleLabel];
|
|
|
|
|
|
- NSInteger curType = 0;// 0 上传中 1 失败 2 完成
|
|
|
- if(section == 2){
|
|
|
- curType = 2;
|
|
|
- }
|
|
|
- else if(section == 1){
|
|
|
- if(backupsingArr.count == 0){
|
|
|
- curType = 2;
|
|
|
- }
|
|
|
- else if(backupsfailArr.count == 0){
|
|
|
- curType = 2;
|
|
|
- }
|
|
|
- else{
|
|
|
- curType = 1;
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- if(backupsingArr.count > 0){
|
|
|
- curType = 0;
|
|
|
- }
|
|
|
- else if(backupsfailArr.count > 0){
|
|
|
- curType = 1;
|
|
|
- }
|
|
|
- else{
|
|
|
- curType = 2;
|
|
|
- }
|
|
|
+ if(_curDataArr.count == 0){
|
|
|
+ return headView;
|
|
|
}
|
|
|
|
|
|
+ photosBackupsTaskModel *model = _curDataArr.firstObject;
|
|
|
+
|
|
|
NSString *text = @"";
|
|
|
- if(curType == 0){
|
|
|
+ if(model.curBackupsState == backupsStateUploading
|
|
|
+ ||model.curBackupsState == backupsStateSuspend){
|
|
|
text = NSLocalizedString(@"File_Transfer_List_head_title_ing",nil);
|
|
|
- text = [[NSString alloc] initWithFormat:@"%@(%ld)",text,backupsingArr.count];
|
|
|
+ text = [[NSString alloc] initWithFormat:@"%@(%ld)",text,model.count - model.didBackupsCount - model.failCount];
|
|
|
}
|
|
|
- else if(curType == 1){
|
|
|
+ else if(model.curBackupsState == backupsStateFail){
|
|
|
text = NSLocalizedString(@"File_Transfer_List_head_title_fail",nil);
|
|
|
- text = [[NSString alloc] initWithFormat:@"%@(%ld)",text,backupsfailArr.count];
|
|
|
+ text = [[NSString alloc] initWithFormat:@"%@(%ld)",text,model.didBackupsCount];
|
|
|
}
|
|
|
else{
|
|
|
text = NSLocalizedString(@"File_Transfer_List_head_title_done",nil);
|
|
|
- text = [[NSString alloc] initWithFormat:@"%@(%ld)",text,backupsDoneArr.count];
|
|
|
+ text = [[NSString alloc] initWithFormat:@"%@(%ld)",text,model.didBackupsCount];
|
|
|
}
|
|
|
|
|
|
titleLabel.text = text;
|
|
@@ -320,120 +210,17 @@
|
|
|
|
|
|
-(void)reloadDataFun{
|
|
|
mainBlock(^{
|
|
|
- [self RefresHeadUIFun];
|
|
|
[self reloadData];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-#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;
|
|
|
-
|
|
|
- if(tag == 100){
|
|
|
- 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];
|
|
|
-
|
|
|
- headView.titleLabel.text = titleStr;
|
|
|
- [headView.rightButton setTitle:rightStr forState:UIControlStateNormal];
|
|
|
- [headView.rightButton setTitle:rightSelectStr forState:UIControlStateSelected];
|
|
|
-
|
|
|
- }
|
|
|
- else if(tag == 101){
|
|
|
- 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];
|
|
|
- }
|
|
|
- else if(tag == 102){
|
|
|
- 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];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 点击全选
|
|
|
-- (void)setIsSelectAllType:(BOOL)isSelectAllType
|
|
|
-{
|
|
|
- _selectModelArr = [NSMutableArray arrayWithArray:_curDataArr];
|
|
|
- [self reloadDataFun];
|
|
|
-}
|
|
|
-
|
|
|
--(void)setIsEditType:(BOOL)isEditType
|
|
|
-{
|
|
|
- _isEditType = isEditType;
|
|
|
-
|
|
|
- if(_isEditType){
|
|
|
- //_bgScrollV.scrollEnabled = NO;
|
|
|
- }
|
|
|
- else{
|
|
|
- //_bgScrollV.scrollEnabled = YES;
|
|
|
- [_selectModelArr removeAllObjects];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- [self reloadDataFun];
|
|
|
-}
|
|
|
-
|
|
|
#pragma mark cell长按时间
|
|
|
- (void)didLongPressClickFun{
|
|
|
- self.isEditType = YES;
|
|
|
if(self->_didLongPressClick){
|
|
|
self->_didLongPressClick();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#pragma mark 单个点击选中 取消
|
|
|
-- (void)selectModelOneByOne:(uploadFileDataModel*)model BySelect:(BOOL)isSelcet
|
|
|
-{
|
|
|
- if(isSelcet){
|
|
|
- [_selectModelArr addObject:model];
|
|
|
- }
|
|
|
- else{
|
|
|
- [_selectModelArr removeObject:model];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 单个点击选中后删除
|
|
|
-- (void)deleteModelOneByOneFun{
|
|
|
-// if(!_selectModelArr || _selectModelArr.count==0){
|
|
|
-//
|
|
|
-// return;
|
|
|
-// }
|
|
|
-//
|
|
|
-// KWeakSelf
|
|
|
-// [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_selectModelArr withDelCache:YES complete:^(BOOL isSuccess) {
|
|
|
-// HLog(@"isSuccess:%d",isSuccess);
|
|
|
-//
|
|
|
-// if(isSuccess){
|
|
|
-// NSMutableArray *curArr = self->_curDataArr;
|
|
|
-// [curArr removeObjectsInArray:self->_selectModelArr];
|
|
|
-// [weakSelf reloadDataFun];
|
|
|
-// self->_selectModelArr = [NSMutableArray new];
|
|
|
-// }
|
|
|
-// }];
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
#pragma mark 处理上传中的 状态点击事件
|
|
|
- (void)handleBackupsingStateTapFunBy:(BOOL)isSuspendType with:(photosBackupsTaskModel*)model
|