12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577 |
- //
- // 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];
- });
-
- }];
- }
- //处理文件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];
- });
-
- }];
- }
- #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
|