123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536 |
- //
- // 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];
-
- 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 isUploadingType = [nasMixUploadManager shareManager].isUploadIngType;
- //判断是否要重新拿数据
- BOOL isNeedRegetDataType = !isUploadingType;
-
- 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;
- }
-
- NSMutableArray *curLoadIngArr = Arr[0];
- //不是上传视频和进来的 所以上传状态(上传中和等待)改为重新上传
- if(!weakSelf.isUploadingType && isNeedRegetDataType){
- //改为暂停
- // for (uploadFileDataModel * curModel in curLoadIngArr) {
- // curModel.curUploadStateType = uploadStateSuspend;
- // }
- //改为重新上传
- NSMutableArray *handleUploadArr = [NSMutableArray new];
- for (uploadFileDataModel * curModel in curLoadIngArr) {
- 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
-
- if(_nonWifiTipViewHeight <=0){
- 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) {
- _nonWifiTipViewHeight = 56;
- [self RefreshBaseUIFun];
- self.nonWifiTipInRecordV.hidden = NO;
- }
- else{
- _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
|