1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549 |
- //
- // 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 ()<UIScrollViewDelegate,UIDocumentPickerDelegate>
- //选中的项
- @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];
- });
-
- }];
- }
- #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<uploadingArr.count; i++) {
- // uploadFileDataModel*preModel = uploadingArr[i];
- // if(preModel.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
- // [_leftTableView.uploadingArr replaceObjectAtIndex:i withObject:uploadFileDataMod];
- // break;
- // }
- // }
-
- if(uploadFileDataMod.curUploadStateType == uploadStateDone
- || uploadFileDataMod.curUploadStateType == uploadStateFail){
- [self RefreshUploadViewFun];
- }
- else{
- [_leftTableView RefreshAllDataFun];
- }
- }
- - (void)uploadFileSuspendAllFun:(NSNotification*)not
- {
- NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
-
- for (int i=0; i<uploadingArr.count; i++) {
- uploadFileDataModel*preModel = uploadingArr[i];
- if(preModel.curUploadStateType == uploadStateUploading
- ||preModel.curUploadStateType == uploadStateWait){
- preModel.curUploadStateType = uploadStateSuspend;
- //break;
- }
- }
- }
- #pragma mark 那上传那边的数据来更新页面
- - (void)RefreshUploadViewFun
- {
- KWeakSelf
- [[nasUploadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
- //[weakSelf setRecordBodyDataFunBy:Arr];
-
- if(!Arr ||Arr.count != 3){
- HLog(@"数据库出错\n\n\n");
- return;
- }
-
- mainBlock(^{
- weakSelf.leftTableView.outSideDataArr = Arr;
- //[weakSelf handleUploadingRightButFun];
- });
- }];
- }
- #pragma mark 按钮点击
- - (void)didClickButFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
- if(tag == 1){
- self.isEditType = NO;
- //self.uploadFileRecordBodyV.isEditType = NO;
-
- if(_selectIndex == 1){
- self.leftTableView.isEditType = NO;
- }
- else if(_selectIndex == 2){
- self.midTableView.isEditType = NO;
- }
- else if(_selectIndex == 3){
- //self.rightTableView.isEditType = NO;
- }
-
- }
- else{
- //self.uploadFileRecordBodyV.isSelectAllType = YES;
-
- but.selected = !but.selected;
-
- BOOL curSelectAllType = but.selected;
-
- if(_selectIndex == 1){
- self.leftTableView.isSelectAllType = curSelectAllType;
- }
- else if(_selectIndex == 2){
- self.midTableView.isSelectAllType = curSelectAllType;
- }
- else if(_selectIndex == 3){
- //self.rightTableView.isSelectAllType = YES;
- }
- else if(_selectIndex == 4){
- self.curReceiveView.isSelectAllType = curSelectAllType;
- }
- }
- }
- -(void)setIsEditType:(BOOL)isEditType
- {
- _isEditType = isEditType;
-
- _leftButton.hidden = !isEditType;
- _rightButton.hidden = !isEditType;
- self.backBtn.hidden = isEditType;
-
- _uploadFileRecordEditBottomV.hidden = !isEditType;
- _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
- _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
-
- //_leftHeadView.rightButton.userInteractionEnabled = !isEditType;
-
- _curReceiveView.isEditType = isEditType;
-
- if(_isEditType){
-
- CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15 - (60 + safeArea + AdaptTabHeight);
- [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
- make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top);
- }];
-
- [_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);
- }];
- }
- else{
- CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
- [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- 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);
- }];
- }
- }
- #pragma mark 点击上传中的全部暂停
- - (void)didClickAllSuspendInLoadingFun
- {
- _leftTableView.uploadingHeadView.rightButton.selected = !_leftTableView.uploadingHeadView.rightButton.selected;
-
- if(_leftTableView.uploadingHeadView.rightButton.selected){
- //[[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
- [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
- [_leftTableView reloadDataFun];
- }
- else{
- NSMutableArray *leftArr = _leftTableView.uploadingArr;
- //[[uploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
- [[nasUploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
- }
- }
- #pragma mark 点击上传成功的清空记录
- - (void)didClickClearRecordInDoneFun
- {
- // 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 didClickClearAllRecordInUploadDoneFun: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_done_Tip_msg",nil)
- imageStr:@""
- cancelTitle:NSLocalizedString(@"other_cancel",nil)
- okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
- didClickOk:^{
- [weakSelf ClearAllRecordInDoneFun];
- } didClickCancel:^{
-
- }];
- nextVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self presentViewController:nextVC animated:YES completion:^{
- nextVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
- #pragma mark 确认要删除上传完成的任务
- - (void)didClickClearAllRecordInUploadDoneFun:(BOOL)isDeleteAllType
- {
- if(isDeleteAllType){
- [self delFileListFunWithData:_leftTableView.uploadDoneArr];
- }
-
- [self ClearAllRecordInDoneFun];
- }
- - (void)ClearAllRecordInDoneFun
- {
- [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadDoneArr withDelCache:YES complete:^(BOOL isSuccess) {
- HLog(@"isSuccess:%d",isSuccess);
- if(isSuccess){
- [self->_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<downloadingArr.count; i++) {
- couldPhoneFileModel*preModel = downloadingArr[i];
- if(preModel.bg_id.integerValue == downloadTaskMod.bg_id.integerValue){
- [_midTableView.downloadingArr replaceObjectAtIndex:i withObject:downloadTaskMod];
- break;
- }
- }
-
- if(downloadTaskMod.curDownloadStateType == downloadStateDone
- ||downloadTaskMod.curDownloadStateType == downloadStateFail){
- [self getDownloadDataInDatabaseFun:NO];
- }
- else{
- [_midTableView RefreshAllDataFun];
- }
- }
- - (void)downloadFileSuspendAllFun:(NSNotification*)not
- {
- NSMutableArray *downloadingArr = _midTableView.downloadingArr;
-
- for (int i=0; i<downloadingArr.count; i++) {
- couldPhoneFileModel*preModel = downloadingArr[i];
- if(preModel.curDownloadStateType == downloadStateUploading
- ||preModel.curDownloadStateType == downloadStateWait){
- preModel.curDownloadStateType = downloadStateSuspend;
- //break;
- }
- }
-
- [_midTableView RefreshAllDataFun];
- }
- #pragma mark 1.3版本UI修改后 下载文件列表的头部点击事件
- - (void)didClikRightButInDownloadTableVieFunBy:(NSInteger)section
- {
- if(section == 0){
- [self didClickAllSuspendInDownLoadingFun];
- }
- else if(section == 1){//成功
- [self didClickClearDownLoadRecordInDoneFun];
- }
- else if(section == 2){//失败
- [self didClickClearRecordInDownLoadFailFun];
- }
- }
- #pragma mark 点击下载中的全部暂停
- - (void)didClickAllSuspendInDownLoadingFun
- {
- _midTableView.downloadingHeadView.rightButton.selected = !_midTableView.downloadingHeadView.rightButton.selected;
-
- if(_midTableView.downloadingHeadView.rightButton.selected){
- [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
- }
- else{
- NSMutableArray *leftArr = _midTableView.downloadingArr;
- [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:leftArr withAll:YES];
- }
- }
- #pragma mark 点击下载成功的清空记录
- - (void)didClickClearDownLoadRecordInDoneFun
- {
- /*弹窗提示二次确认*/
- KWeakSelf
- ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
- msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
- imageStr:@""
- cancelTitle:NSLocalizedString(@"other_cancel",nil)
- okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
- didClickOk:^{
- [weakSelf ClearAllRecordInDownloadDoneFun];
- } didClickCancel:^{
-
- }];
- nextVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self presentViewController:nextVC animated:YES completion:^{
- nextVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
- - (void)ClearAllRecordInDownloadDoneFun
- {
- [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
- }
- #pragma mark 点击下载失败的清空记录
- - (void)didClickClearRecordInDownLoadFailFun
- {
- /*弹窗提示二次确认*/
- 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 ClearAllRecordInDownloadFailFun];
- } didClickCancel:^{
-
- }];
- nextVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self presentViewController:nextVC animated:YES completion:^{
- nextVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
- - (void)ClearAllRecordInDownloadFailFun
- {
- [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
- }
- /**********************************接收相关******************************************/
- - (void)setIsReceiveType:(NSInteger)isReceiveType
- {
- _isReceiveType = isReceiveType;
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.curReceiveView.isReceiveType = isReceiveType;
- [weakSelf.curReceiveView getAllDataFun];
- [weakSelf delayChangeUIFunWithIndex:4];
- });
- }
- #pragma mark 删除云机文件数据
- - (void)delFileListFunWithData:(NSArray*)delDataArr
- {
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
-
- if(delDataArr){
-
- NSMutableArray*pathArr = [NSMutableArray new];
- for (uploadFileDataModel *uploadFileDataMod in delDataArr) {
- NSString *uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
-
- if(uploadDefaultPath && uploadDefaultPath.length > 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
|