// // uoloadFileRecordViewController.m // 隐私保护 // // Created by xd h on 2023/11/13. // #import "uploadFileRecordViewController.h" #import "uploadFileManager.h" #import "uploadFileDataModel.h" #import "uploadFileRecordheadView.h" //#import "uploadFileRecordBodyView.h" #import "uploadFileRecordEditBottomView.h" #import "uploadFileRecordBgScorllView.h" #import "uploadFileRecordTableView.h" #import "uploadFileRecordTableViewHeadView.h" #import "ComontAlretViewController.h" #import "backupsFilerecordTableView.h" #import "photosBackupsTaskModel.h" //#import "downloadManager.h" #import "downloadFileRecordTableView.h" #import "MySetViewController.h" #import "receiveView.h" #import "ComontAlretDeleteTypeViewController.h" #import "nonWifiTipInRecordView.h" #import "fileTransfeSetViewController.h" @interface uploadFileRecordViewController () //选中的项 @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems; @property (nonatomic, strong) uploadFileRecordheadView *uploadFileRecordheadV; @property (nonatomic, strong) uploadFileRecordBgScorllView *uploadFileRecordBgScorllV; @property (nonatomic, strong) uploadFileRecordTableView *leftTableView; @property (nonatomic, strong) downloadFileRecordTableView *midTableView; @property (nonatomic, strong) backupsFilerecordTableView *rightTableView; @property (nonatomic, strong) receiveView *curReceiveView; @property (nonatomic, strong) nonWifiTipInRecordView *nonWifiTipInRecordV; @property (nonatomic, assign) CGFloat nonWifiTipViewHeight; //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView; //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *midHeadView; //@property (nonatomic, strong) NSMutableArray *allDataArr; @property (nonatomic, strong) UIButton *leftButton; @property (nonatomic, strong) UIButton *rightButton; @property (nonatomic, strong) uploadFileRecordEditBottomView *uploadFileRecordEditBottomV; @property (nonatomic,assign) BOOL isEditType; @property(nonatomic,assign) NSInteger selectIndex;// 从1开始 @property (nonatomic,assign) BOOL didGetUploadDataType; @property (nonatomic,assign) BOOL didGetDownloadDataType; @property (nonatomic,assign) BOOL didGetbackupsloadDataType; @property (nonatomic, copy) NSString *h5ShareDownloadUrl; @property (nonatomic,assign) BOOL isNotFirstPushType;//是否第一次进来 @end @implementation uploadFileRecordViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //[self.view setBackgroundColor:HWF5F7FAColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileRefreshFun:) name:uploadFileRefreshNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileSuspendAllFun:) name:uploadFileSuspendAllNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backupsFileRefreshFun:) name:backupsFileRefreshNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileRefreshFun:) name:downloadFileRefreshNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileSuspendAllFun:) name:downloadFileSuspendAllNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskFinishedNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkStateChange:) name:NetWorkChangeNotification object:nil]; [self.view setBackgroundColor:[UIColor whiteColor]]; self.titleLabel.text = NSLocalizedString(@"my_set_no_File_Transfer_List",nil) ; [self.toolBar setHidden:YES]; [self.navigationBar setHidden:YES]; [self.navBarBGView setHidden:NO]; self.navBarBGView.backgroundColor = [UIColor whiteColor]; [self initbaseUIFun]; //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Transmission_record"]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if(_isNotFirstPushType){//判断是否第一次进入 非第一次进入 不处理下面的逻辑 if(!self.nonWifiTipInRecordV.hidden){ if([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN){//目前是流量模式 BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)]; if(isCanUseCellular){ [self networkStateChange:nil];// } } } return; } _isNotFirstPushType = YES; if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024] && _isDownloadingType){ mainBlock(^{ [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show]; }); // [self.navigationController popViewControllerAnimated:YES]; // return; } [self getAllDataFun]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [SVProgressHUD dismiss]; } #pragma mark 获取数据 - (void)getAllDataFun { [SVProgressHUD show];; if(!_isUploadingType){ [self getUploadDataInDatabaseFun]; } if(!_isDownloadingType){ [self getDownloadDataInDatabaseFun:YES]; } else{ [self delayChangeUIFunWithIndex:2]; } //检测是否还有没保存的任务 [[nasDownloadFileManager shareInstance] checkDownloadDonePlistInfoFun]; [self getBackupsDatabaseFun]; if(!_isReceiveType){ [_curReceiveView getAllDataFun]; } } - (void)handleRemoveIndicator { if(_didGetUploadDataType && _didGetDownloadDataType && _didGetbackupsloadDataType){ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [SVProgressHUD dismiss]; }); } } //下载 2 接收 4 - (void)delayChangeUIFunWithIndex:(NSInteger)index { _selectIndex = index; KWeakSelf dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf didClickHeadFun:self->_selectIndex]; [weakSelf didScorllBodyFun:self->_selectIndex]; }); } #pragma mark UI - (void)initbaseUIFun { _uploadFileRecordheadV = [[uploadFileRecordheadView alloc] init]; [self.view addSubview:_uploadFileRecordheadV]; [_uploadFileRecordheadV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.top.mas_equalTo(self.navBarBGView.mas_bottom).offset(15.0); make.height.mas_equalTo(50); }]; _selectIndex = 1; KWeakSelf #pragma mark 头部点击事件 _uploadFileRecordheadV.didClickButFun = ^(NSInteger index) { [weakSelf didClickHeadFun: index]; }; _nonWifiTipViewHeight = 0; [self.view addSubview:self.nonWifiTipInRecordV]; //AFNetworkReachabilityStatus state = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus; BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)]; //当前网络为流量 与流量传输没开 if ([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN && !isCanUseCellular) { _nonWifiTipViewHeight = 56; } [self.nonWifiTipInRecordV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.top.mas_equalTo(self.uploadFileRecordheadV.mas_bottom).offset(0.0); make.height.mas_equalTo(_nonWifiTipViewHeight); }]; if(_nonWifiTipViewHeight == 0){ self.nonWifiTipInRecordV.hidden = YES; } #pragma mark 点击去开启 self.nonWifiTipInRecordV.didClickBut = ^{ [weakSelf gotoTranSettingVCFun]; }; CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - _nonWifiTipViewHeight - 15; _uploadFileRecordBgScorllV= [[uploadFileRecordBgScorllView alloc] init]; _uploadFileRecordBgScorllV.delegate = self; _uploadFileRecordBgScorllV.pagingEnabled = YES; //_uploadFileRecordBgScorllV.backgroundColor = [UIColor yellowColor]; [self.view addSubview:_uploadFileRecordBgScorllV]; [_uploadFileRecordBgScorllV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); if(_nonWifiTipViewHeight > 0){ make.top.mas_equalTo(self.nonWifiTipInRecordV.mas_bottom).offset(0.0); } else{ make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0); } make.bottom.mas_equalTo(0); }]; _leftTableView = [[uploadFileRecordTableView alloc] init]; _leftTableView.tag =100; [_uploadFileRecordBgScorllV addSubview:_leftTableView]; [_leftTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*0.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; _leftTableView.didLongPressClick = ^{ weakSelf.isEditType = YES; }; _leftTableView.didClickSectionHeadViewRightButton = ^(NSInteger section) { [weakSelf didClikRightButInUploadTableVieFunBy:section]; }; _leftTableView.didNeedRefreshGetDatabaseFun = ^{ [weakSelf RefreshUploadViewFun]; }; _midTableView = [[downloadFileRecordTableView alloc] init]; _midTableView.tag = 101; [_uploadFileRecordBgScorllV addSubview:_midTableView]; [_midTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*1.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; _midTableView.didLongPressClick = ^{ weakSelf.isEditType = YES; }; _midTableView.didClickSectionHeadViewRightButton = ^(NSInteger section) { [weakSelf didClikRightButInDownloadTableVieFunBy:section]; }; _midTableView.didNeedRefreshGetDatabaseFun = ^{ [weakSelf getDownloadDataInDatabaseFun:NO]; }; _rightTableView = [[backupsFilerecordTableView alloc] init]; _rightTableView.tag = 102; [_uploadFileRecordBgScorllV addSubview:_rightTableView]; [_rightTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*2.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; _rightTableView.didLongPressClick = ^{ // weakSelf.isEditType = YES; }; //接收 _curReceiveView = [[receiveView alloc] init]; _curReceiveView.tag = 103; [_uploadFileRecordBgScorllV addSubview:_curReceiveView]; [_curReceiveView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*3.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; _curReceiveView.didLongPressClick = ^{ weakSelf.isEditType = YES; }; _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*4.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]; // }; _leftButton = [[UIButton alloc] init]; [_leftButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal]; _leftButton.titleLabel.font = [UIFont systemFontOfSize:18.0]; _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [_leftButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside]; _leftButton.tag = 1; [_leftButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal]; _leftButton.hidden = YES; [self.navBarBGView addSubview:_leftButton]; [_leftButton mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(80); make.left.mas_equalTo(15); make.height.mas_equalTo(self.backBtn.mas_height); make.centerY.mas_equalTo(self.backBtn.mas_centerY); }]; _rightButton = [[UIButton alloc] init]; [_rightButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal]; _rightButton.titleLabel.font = [UIFont systemFontOfSize:18.0]; _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight; [_rightButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside]; _rightButton.tag = 2; [_rightButton setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal]; [_rightButton setTitle:NSLocalizedString(@"File_upload_cancel_select_all",nil) forState:UIControlStateSelected]; _rightButton.hidden = YES; [self.navBarBGView addSubview:_rightButton]; //多国语言适配 NSString *languageCode = [NSLocale preferredLanguages][0]; if([languageCode rangeOfString:@"ja-"].location != NSNotFound) { _rightButton.titleLabel.font = [UIFont systemFontOfSize:13.0]; _leftButton.titleLabel.font = [UIFont systemFontOfSize:13.0]; } [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(90); make.right.mas_equalTo(-15); make.height.mas_equalTo(self.backBtn.mas_height); make.centerY.mas_equalTo(self.backBtn.mas_centerY); }]; _uploadFileRecordEditBottomV = [[uploadFileRecordEditBottomView alloc] init]; _uploadFileRecordEditBottomV.hidden = YES; [self.view addSubview:_uploadFileRecordEditBottomV]; [_uploadFileRecordEditBottomV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.height.mas_equalTo(60 + safeArea); make.bottom.mas_equalTo(0); }]; _uploadFileRecordEditBottomV.didClickButFun = ^{ //[weakSelf.uploadFileRecordBodyV deleteModelOneByOneFun]; [weakSelf didClickBottomDeleteFun]; }; } #pragma mark 懒加载 - (nonWifiTipInRecordView*)nonWifiTipInRecordV { if(!_nonWifiTipInRecordV){ _nonWifiTipInRecordV = [[nonWifiTipInRecordView alloc] init]; } return _nonWifiTipInRecordV; } #pragma mark 底部删除点击 -(void)didClickBottomDeleteFun { NSMutableArray *selectModelArr ;//= _leftTableView.selectModelArr; if(_selectIndex == 1){ selectModelArr = _leftTableView.selectModelArr; } else if(_selectIndex == 2){ selectModelArr = _midTableView.selectModelArr; } else if(_selectIndex == 3){ return; } else if(_selectIndex == 4){ selectModelArr = _curReceiveView.selectModelArr; } if(!selectModelArr || selectModelArr.count== 0){ [[iToast makeText:NSLocalizedString(@"File_upload_Record_delete_noFile",nil)] show]; return; } if(_selectIndex == 1){//上传相关特殊处理 NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil); NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil); KWeakSelf ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc] initWithTitle:titleStr msg:@"" imageStr:@"" cancelTitle:NSLocalizedString(@"other_cancel",nil) okTitle:NSLocalizedString(@"other_confirm",nil) otherTitle:tipStr isOkBtnHighlight:YES didClickOk:^(BOOL isDeleteAll) { [weakSelf didClickDeleteOkButBy:isDeleteAll]; } didClickCancel:^{ }]; curAlretVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:curAlretVC animated:YES completion:^{ curAlretVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } else{ NSString *delTipTip = NSLocalizedString(@"box_receive_delete_msg",nil); /*弹窗提示二次确认*/ KWeakSelf ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil) msg:delTipTip imageStr:@"" cancelTitle:NSLocalizedString(@"other_cancel",nil) okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES didClickOk:^{ [weakSelf didClickBottomDeleteFunAfterAleartFun]; } didClickCancel:^{ }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } } #pragma mark 选中上传任务的删除的处理 - (void)didClickDeleteOkButBy:(BOOL)isDeleteAll { if(isDeleteAll){//删除云机上的文件 [self delFileListFunWithData:_leftTableView.selectModelArr]; } [self didClickBottomDeleteFunAfterAleartFun]; } -(void)didClickBottomDeleteFunAfterAleartFun { [SVProgressHUD show]; if(_selectIndex == 1){ [_leftTableView deleteModelOneByOneFun]; } else if(_selectIndex == 2){ [_midTableView deleteModelOneByOneFun]; } else if(_selectIndex == 3){ //没有操作 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [SVProgressHUD dismiss]; }); } else if(_selectIndex == 4){ [_curReceiveView deleteModelOneByOneFun]; [SVProgressHUD dismiss]; } } #pragma mark 头部点击 背景滚动 - (void)didClickHeadFun:(NSInteger)index { //_uploadFileRecordBodyV.selectIndex = index; _selectIndex = index; _uploadFileRecordBgScorllV.contentOffset = CGPointMake(SCREEN_W *(index -1), 0); } - (void)didScorllBodyFun:(NSInteger)index { _uploadFileRecordheadV.selectIndex = index; _selectIndex = index; } #pragma mark 1.3版本UI修改后 上传文件列表的内容点击时间 - (void)didClikRightButInUploadTableVieFunBy:(NSInteger)section { if(section == 0){ [self didClickAllSuspendInLoadingFun]; } else if(section == 1){//成功 [self didClickClearRecordInDoneFun]; } else if(section == 2){//失败 [self didClickClearRecordInFailFun]; } } #pragma mark 背景滚动代理 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { if(scrollView != _uploadFileRecordBgScorllV) return; CGFloat x = scrollView.contentOffset.x; NSInteger index = (x+1)/SCREEN_W; index += 1;//因为头部是从1开始的 //HLog(@"index:%ld",index); [self didScorllBodyFun:index]; } -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems { KWeakSelf mainBlock(^{ weakSelf.didGetUploadDataType = YES; [weakSelf handleRemoveIndicator]; }); [self realGotoUploadFile:indexPathsForSelectedItems]; } - (void)realGotoUploadFile:(NSMutableArray *)indexPathsForSelectedItems { KWeakSelf [[nasUploadFileManager shareInstance] handlTZAssetModelToUploadFileDataFunBy:indexPathsForSelectedItems complete:^(NSMutableArray * _Nonnull Arr) { //NSMutableArray *arr1 = Arr; //[weakSelf setRecordBodyDataFunBy:arr1]; //weakSelf.leftTableView.curDataArr = Arr[0]; mainBlock(^{ weakSelf.leftTableView.outSideDataArr = Arr; [weakSelf handleUploadingRightButFun:YES]; }); }]; } //处理文件app上传的文件 -(void)gotoUploadFileByFileApp:(NSArray*)FileUrls{ KWeakSelf mainBlock(^{ weakSelf.didGetUploadDataType = YES; [weakSelf handleRemoveIndicator]; }); [self realGotoUploadFileByFileApp:FileUrls]; } - (void)realGotoUploadFileByFileApp:(NSArray *)URLArr { KWeakSelf [[nasUploadFileManager shareInstance] handlUrlToUploadFileDataFunBy:URLArr complete:^(NSMutableArray * _Nonnull Arr) { //NSMutableArray *arr1 = Arr; //[weakSelf setRecordBodyDataFunBy:arr1]; //weakSelf.leftTableView.curDataArr = Arr[0]; mainBlock(^{ weakSelf.leftTableView.outSideDataArr = Arr; [weakSelf handleUploadingRightButFun:YES]; }); }]; } //处理文件录音上传的文件 -(void)gotoUploadFileByRecord:(NSArray*)recordFileArr { KWeakSelf mainBlock(^{ weakSelf.didGetUploadDataType = YES; [weakSelf handleRemoveIndicator]; }); //KWeakSelf [[nasUploadFileManager shareInstance] handlToRecorUploadFileDataFunBy:recordFileArr complete:^(NSMutableArray * _Nonnull Arr) { mainBlock(^{ weakSelf.leftTableView.outSideDataArr = Arr; [weakSelf handleUploadingRightButFun:YES]; }); }]; } #pragma mark 读取数据库数据 - (void)getUploadDataInDatabaseFun { //查询是否为nas上传中 BOOL isnasUploadingType = [nasMixUploadManager shareManager].isUploadIngType; //判断是否要重新拿数据 BOOL isNeedRegetDataType = !isnasUploadingType; KWeakSelf [[nasUploadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) { //[weakSelf setRecordBodyDataFunBy:Arr]; weakSelf.didGetUploadDataType = YES; [weakSelf handleRemoveIndicator]; if(!Arr ||Arr.count != 3){ HLog(@"数据库出错\n\n\n"); return; } //不是上传视频和进来的 所以上传状态(上传中和等待)改为重新上传 if(!weakSelf.isUploadingType && isNeedRegetDataType){ //改为暂停 // for (uploadFileDataModel * curModel in curLoadIngArr) { // curModel.curUploadStateType = uploadStateSuspend; // } //改为重新上传 if(!isnasUploadingType){ NSMutableArray *curLoadIngArr = Arr[0]; NSMutableArray *handleUploadArr = [NSMutableArray new]; for (uploadFileDataModel * curModel in curLoadIngArr) { if(!curModel){ continue; } if(curModel.curUploadStateType != uploadStateSuspend) { [handleUploadArr addObject:curModel]; } } if(handleUploadArr.count >0){ //[[uploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES]; [[nasUploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES]; } } } mainBlock(^{ weakSelf.leftTableView.outSideDataArr = Arr; [weakSelf handleUploadingRightButFun:NO]; }); }]; } - (void)getBackupsDatabaseFun { KWeakSelf [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) { mainBlock(^{ weakSelf.didGetbackupsloadDataType = YES; [weakSelf handleRemoveIndicator]; weakSelf.rightTableView.curDataArr = array; }); }]; } #pragma mark 读取数据库数据 - (void)getDownloadDataInDatabaseFun:(BOOL)isRegetType { if(isRegetType){ //查询是否为nas下载中 BOOL isDownLoadIngType = [nasDownloadManager shareManager].isDownLoadIngType; //判断是否要重新拿数据 isRegetType = !isDownLoadIngType; } KWeakSelf [[nasDownloadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) { weakSelf.didGetDownloadDataType = YES; [weakSelf handleRemoveIndicator]; if(!Arr ||Arr.count != 3){ HLog(@"数据库出错\n\n\n"); return; } NSMutableArray *curLoadIngArr = Arr[0]; //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停 if(![nasDownloadManager shareManager].isDownLoadIngType && isRegetType){ // for (couldPhoneFileModel * curModel in curLoadIngArr) { // curModel.curDownloadStateType = downloadStateSuspend; // } //改为重新下载 NSMutableArray *handleDownloadArr = [NSMutableArray new]; for (couldPhoneFileModel * curModel in curLoadIngArr) { if(curModel.curDownloadStateType != downloadStateSuspend) { [handleDownloadArr addObject:curModel]; } } if(handleDownloadArr.count >0){ [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:handleDownloadArr withAll:NO]; } } mainBlock(^{ weakSelf.midTableView.outSideDataArr = Arr; [weakSelf.midTableView reloadDataFun]; [weakSelf handleDownloadingRightButFun]; }); }]; } #pragma mark 处理上传中的 全部暂停等 - (void)handleUploadingRightButFun:(BOOL)isUserUploadIngType { // if(_leftTableView.uploadingArr.count == 0){ // //不处理 // } // else{ // NSMutableArray *upLoadingArr = [uploadFileManager shareInstance].fileModelDataArr; // BOOL isUploadIngType = [uploadFileManager shareInstance].isUploadIngType; // // if(!isUserUploadIngType // &&(!upLoadingArr ||upLoadingArr.count == 0 || !isUploadIngType)){//不是上传状态 // _leftTableView.uploadingHeadView.rightButton.selected = YES; // } // else if(upLoadingArr.count == _leftTableView.uploadingArr.count){ // _leftTableView.uploadingHeadView.rightButton.selected = NO; // } // else{ // _leftTableView.uploadingHeadView.rightButton.selected = YES; // } // } } #pragma mark 处理下载中的 全部暂停等 - (void)handleDownloadingRightButFun { if(_midTableView.downloadingArr.count == 0){ //不处理 } else{ NSMutableArray *downloadingArr = [nasDownloadFileManager shareInstance].downLoadFileModelDataArr; BOOL isDownloadIngType = [nasDownloadManager shareManager].isDownLoadIngType; if(!downloadingArr ||downloadingArr.count == 0 || !isDownloadIngType){//不是下载状态 _midTableView.downloadingHeadView.rightButton.selected = YES; } else if(downloadingArr.count == _midTableView.downloadingArr.count){ _midTableView.downloadingHeadView.rightButton.selected = NO; } else{ _midTableView.downloadingHeadView.rightButton.selected = YES; } } } - (void)uploadFileRefreshFun:(NSNotification*)not { uploadFileDataModel *uploadFileDataMod = [not object]; //HLog(@"%@",uploadFileDataMod); uploadFileDataMod.curTimeInterval = [[NSDate date] timeIntervalSince1970]; NSMutableArray *uploadingArr = _leftTableView.uploadingArr; //HLog(@"传输列表的上传任务:%@",uploadingArr); // for (int i=0; i_leftTableView.uploadDoneArr removeAllObjects]; [self->_leftTableView reloadDataFun]; } }]; } #pragma mark 点击上传失败的清空记录 - (void)didClickClearRecordInFailFun { // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil); // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil); // // KWeakSelf // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc] // initWithTitle:titleStr // msg:nil // imageStr:nil // cancelTitle:NSLocalizedString(@"other_cancel",nil) // okTitle:NSLocalizedString(@"other_confirm",nil) // otherTitle:tipStr // isOkBtnHighlight:YES // didClickOk:^(BOOL isDeleteAll) { // [weakSelf didClickClearAllRecordInUploadFailFun:isDeleteAll]; // } didClickCancel:^{ // // }]; // // curAlretVC.modalPresentationStyle = UIModalPresentationCustom; // // [self presentViewController:curAlretVC animated:YES completion:^{ // curAlretVC.view.superview.backgroundColor = [UIColor clearColor]; // }]; /*弹窗提示二次确认*/ KWeakSelf ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil) msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil) imageStr:@"" cancelTitle:NSLocalizedString(@"other_cancel",nil) okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES didClickOk:^{ [weakSelf ClearAllRecordInFailFun]; } didClickCancel:^{ }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } #pragma mark 确认要删除上传失败的任务 - (void)didClickClearAllRecordInUploadFailFun:(BOOL)isDeleteAllType { if(isDeleteAllType){ [self delFileListFunWithData:_leftTableView.uploadfailArr]; } [self ClearAllRecordInFailFun]; } - (void)ClearAllRecordInFailFun { [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadfailArr withDelCache:YES complete:^(BOOL isSuccess) { HLog(@"isSuccess:%d",isSuccess); if(isSuccess){ [self->_leftTableView.uploadfailArr removeAllObjects]; [self->_leftTableView reloadDataFun]; } }]; } -(void)backBtnPressed{ //[super backBtnPressed]; NSArray *vcArrs = self.navigationController.viewControllers; NSInteger count = vcArrs.count; UIViewController *vc = nil; if(count > 2){ UIViewController *lastVC = vcArrs[count-2]; if([lastVC isKindOfClass:[uploadImageOrVideoViewController class]]){ vc = vcArrs[count-3]; } } if(vc){ [self.navigationController popToViewController:vc animated:YES]; } else{ [self.navigationController popViewControllerAnimated:YES]; } } - (void)backupsFileRefreshFun:(NSNotification*)not { photosBackupsTaskModel *photosBackupsTaskMod = [not object]; //HLog(@"%@",uploadFileDataMod); if(photosBackupsTaskMod.didBackupsOneFileType){ photosBackupsTaskMod.curTimeInterval = 0; photosBackupsTaskMod.preTimeInterval = 0; } else{ photosBackupsTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970]; } _rightTableView.photosBackupsIngTaskModel = photosBackupsTaskMod; } -(void)gotoDownloadFile:(NSMutableArray*)selectedItems { KWeakSelf [[nasDownloadFileManager shareInstance] addNasDownloadRecordFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) { weakSelf.didGetDownloadDataType = YES; [weakSelf handleRemoveIndicator]; if(!Arr ||Arr.count != 3){ HLog(@"数据库出错\n\n\n"); return; } //NSMutableArray *curLoadIngArr = Arr[0]; mainBlock(^{ weakSelf.midTableView.outSideDataArr = Arr; [weakSelf.midTableView reloadDataFun]; //[weakSelf handleUploadingRightButFun]; }); }]; // [[downloadManager shareInstance] handleCouldPhoneFileModelToDownloadFileDataFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) { // // weakSelf.didGetDownloadDataType = YES; // [weakSelf handleRemoveIndicator]; // // if(!Arr ||Arr.count != 3){ // HLog(@"数据库出错\n\n\n"); // return; // } // // //NSMutableArray *curLoadIngArr = Arr[0]; // // mainBlock(^{ // weakSelf.midTableView.outSideDataArr = Arr; // [weakSelf.midTableView reloadDataFun]; // //[weakSelf handleUploadingRightButFun]; // }); // }]; //处理数据埋点 NSString * firstFileType = nil; BOOL isSameFileType = YES; for (couldPhoneFileModel*model in selectedItems) { if(!firstFileType){ firstFileType = model.fileType; } else if(![firstFileType isEqualToString:model.fileType]){ isSameFileType = NO; break; } } if(!isSameFileType){ //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"]; } else if([firstFileType containsString:@"jpg"]){ //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_download"]; } else if([firstFileType isEqualToString:@"video"]){ //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_download"]; } else if([firstFileType isEqualToString:@"audio"]){ //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_download"]; } else{ //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"]; } } #pragma mark nas http下载完成 - (void)downloadTaskFinishedNoti:(NSNotification *)notification { //customDownloadOperation *model = notification.object; //NSString *url = model.url; [self getDownloadDataInDatabaseFun:NO]; } - (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]; NSMutableArray *downloadingArr = _midTableView.downloadingArr; for (int i=0; i 0){ //判断最后一个是否是/ NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1]; if(![lastStr isEqualToString:@"/"]){ uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath]; } NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,uploadFileDataMod.filename]; [pathArr addObject:savePath]; } } [paraDict setValue:pathArr forKey:@"path"]; } //[self showNewIndicatorWithCanBack:YES canTouch:NO]; //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC] //KWeakSelf //@"delFile" [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) { //[weakSelf removeNewIndicator]; SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil]; if(model && model.status == 0){ //[[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show]; } else{ } } failure:^(NSError * _Nonnull error) { //[weakSelf removeNewIndicator]; }]; } #pragma mark 跳转传输设置页面 - (void)gotoTranSettingVCFun { fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new]; [self.navigationController pushViewController:nextVC animated:YES]; } #pragma - mark - 监听网络变化 - (void)networkStateChange:(NSNotification *)notification { //处理UI变化 if([AFNetworkReachabilityManager sharedManager].isReachableViaWiFi){//目前是wifi HLog("wifi 环境") if(_nonWifiTipViewHeight <=0){ HLog("wifi 环境 并且没有显示流量提示") return;//wifi 而且前面没有显示提示开启wifi传输 不需要处理 } _nonWifiTipViewHeight = 0; [self RefreshBaseUIFun]; self.nonWifiTipInRecordV.hidden = YES; } else if([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN){//目前是流量模式 BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)]; //当前网络为流量 与流量传输没开 if (!isCanUseCellular) { HLog("流量 环境 需要显示流量提示") _nonWifiTipViewHeight = 56; [self RefreshBaseUIFun]; self.nonWifiTipInRecordV.hidden = NO; } else{ HLog("流量 环境 需要隐藏流量提示") _nonWifiTipViewHeight = 0; [self RefreshBaseUIFun]; self.nonWifiTipInRecordV.hidden = YES; } } } #pragma mark 更新UI - (void)RefreshBaseUIFun { [self.nonWifiTipInRecordV mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.top.mas_equalTo(self.uploadFileRecordheadV.mas_bottom).offset(0.0); make.height.mas_equalTo(_nonWifiTipViewHeight); }]; CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - _nonWifiTipViewHeight - 15; [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); if(_nonWifiTipViewHeight > 0){ make.top.mas_equalTo(self.nonWifiTipInRecordV.mas_bottom).offset(0.0); } else{ make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0); } make.bottom.mas_equalTo(0); }]; [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*0.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*1.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*2.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(SCREEN_W*3.0); make.width.mas_equalTo(SCREEN_W); make.top.mas_equalTo(0); make.height.mas_equalTo(curHeight); }]; _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*4.0, curHeight); } @end