uploadFileRecordViewController.m 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368
  1. //
  2. // uoloadFileRecordViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/13.
  6. //
  7. #import "uploadFileRecordViewController.h"
  8. #import "uploadFileManager.h"
  9. #import "uploadFileDataModel.h"
  10. #import "uploadFileRecordheadView.h"
  11. //#import "uploadFileRecordBodyView.h"
  12. #import "uploadFileRecordEditBottomView.h"
  13. #import "uploadFileRecordBgScorllView.h"
  14. #import "uploadFileRecordTableView.h"
  15. #import "uploadFileRecordTableViewHeadView.h"
  16. #import "ComontAlretViewController.h"
  17. #import "backupsFilerecordTableView.h"
  18. #import "photosBackupsTaskModel.h"
  19. //#import "downloadManager.h"
  20. #import "downloadFileRecordTableView.h"
  21. #import "MySetViewController.h"
  22. #import "receiveView.h"
  23. #import "ComontAlretDeleteTypeViewController.h"
  24. @interface uploadFileRecordViewController ()<UIScrollViewDelegate,UIDocumentPickerDelegate>
  25. //选中的项
  26. @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
  27. @property (nonatomic, strong) uploadFileRecordheadView *uploadFileRecordheadV;
  28. @property (nonatomic, strong) uploadFileRecordBgScorllView *uploadFileRecordBgScorllV;
  29. @property (nonatomic, strong) uploadFileRecordTableView *leftTableView;
  30. @property (nonatomic, strong) downloadFileRecordTableView *midTableView;
  31. @property (nonatomic, strong) backupsFilerecordTableView *rightTableView;
  32. @property (nonatomic, strong) receiveView *curReceiveView;
  33. //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView;
  34. //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *midHeadView;
  35. //@property (nonatomic, strong) NSMutableArray *allDataArr;
  36. @property (nonatomic, strong) UIButton *leftButton;
  37. @property (nonatomic, strong) UIButton *rightButton;
  38. @property (nonatomic, strong) uploadFileRecordEditBottomView *uploadFileRecordEditBottomV;
  39. @property (nonatomic,assign) BOOL isEditType;
  40. @property(nonatomic,assign) NSInteger selectIndex;// 从1开始
  41. @property (nonatomic,assign) BOOL didGetUploadDataType;
  42. @property (nonatomic,assign) BOOL didGetDownloadDataType;
  43. @property (nonatomic,assign) BOOL didGetbackupsloadDataType;
  44. @property (nonatomic, copy) NSString *h5ShareDownloadUrl;
  45. @end
  46. @implementation uploadFileRecordViewController
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. // Do any additional setup after loading the view.
  50. //[self.view setBackgroundColor:HWF5F7FAColor];
  51. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileRefreshFun:) name:uploadFileRefreshNotification object:nil];
  52. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileSuspendAllFun:) name:uploadFileSuspendAllNotification object:nil];
  53. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backupsFileRefreshFun:) name:backupsFileRefreshNotification object:nil];
  54. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileRefreshFun:) name:downloadFileRefreshNotification object:nil];
  55. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileSuspendAllFun:) name:downloadFileSuspendAllNotification object:nil];
  56. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskFinishedNotification object:nil];
  57. [self.view setBackgroundColor:[UIColor whiteColor]];
  58. self.titleLabel.text = NSLocalizedString(@"my_set_no_File_Transfer_List",nil) ;
  59. [self.toolBar setHidden:YES];
  60. [self.navigationBar setHidden:YES];
  61. [self.navBarBGView setHidden:NO];
  62. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  63. [self initbaseUIFun];
  64. //数据埋点
  65. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Transmission_record"];
  66. }
  67. - (void)viewWillAppear:(BOOL)animated
  68. {
  69. [super viewWillAppear:animated];
  70. if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]){
  71. mainBlock(^{
  72. [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
  73. });
  74. // [self.navigationController popViewControllerAnimated:YES];
  75. // return;
  76. }
  77. [self getAllDataFun];
  78. }
  79. - (void)viewWillDisappear:(BOOL)animated
  80. {
  81. [super viewWillDisappear:animated];
  82. [SVProgressHUD dismiss];
  83. }
  84. #pragma mark 获取数据
  85. - (void)getAllDataFun
  86. {
  87. [SVProgressHUD show];;
  88. if(!_isUploadingType){
  89. [self getUploadDataInDatabaseFun];
  90. }
  91. if(!_isDownloadingType){
  92. [self getDownloadDataInDatabaseFun:YES];
  93. }
  94. else{
  95. [self delayChangeUIFunWithIndex:2];
  96. }
  97. //检测是否还有没保存的任务
  98. [[nasDownloadFileManager shareInstance] checkDownloadDonePlistInfoFun];
  99. [self getBackupsDatabaseFun];
  100. if(!_isReceiveType){
  101. [_curReceiveView getAllDataFun];
  102. }
  103. }
  104. - (void)handleRemoveIndicator
  105. {
  106. if(_didGetUploadDataType
  107. && _didGetDownloadDataType
  108. && _didGetbackupsloadDataType){
  109. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  110. [SVProgressHUD dismiss];
  111. });
  112. }
  113. }
  114. //下载 2 接收 4
  115. - (void)delayChangeUIFunWithIndex:(NSInteger)index
  116. {
  117. _selectIndex = index;
  118. KWeakSelf
  119. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  120. [weakSelf didClickHeadFun:self->_selectIndex];
  121. [weakSelf didScorllBodyFun:self->_selectIndex];
  122. });
  123. }
  124. #pragma mark UI
  125. - (void)initbaseUIFun
  126. {
  127. _uploadFileRecordheadV = [[uploadFileRecordheadView alloc] init];
  128. [self.view addSubview:_uploadFileRecordheadV];
  129. [_uploadFileRecordheadV mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.left.mas_equalTo(15);
  131. make.right.mas_equalTo(-15);
  132. make.top.mas_equalTo(self.navBarBGView.mas_bottom).offset(15.0);
  133. make.height.mas_equalTo(50);
  134. }];
  135. _selectIndex = 1;
  136. KWeakSelf
  137. #pragma mark 头部点击事件
  138. _uploadFileRecordheadV.didClickButFun = ^(NSInteger index) {
  139. [weakSelf didClickHeadFun: index];
  140. };
  141. //CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  142. CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - 15;
  143. _uploadFileRecordBgScorllV= [[uploadFileRecordBgScorllView alloc] init];
  144. _uploadFileRecordBgScorllV.delegate = self;
  145. [self.view addSubview:_uploadFileRecordBgScorllV];
  146. [_uploadFileRecordBgScorllV mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.left.mas_equalTo(0);
  148. make.right.mas_equalTo(0);
  149. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  150. make.bottom.mas_equalTo(0);
  151. }];
  152. _leftTableView = [[uploadFileRecordTableView alloc] init];
  153. _leftTableView.tag =100;
  154. [_uploadFileRecordBgScorllV addSubview:_leftTableView];
  155. [_leftTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  156. make.left.mas_equalTo(SCREEN_W*0.0);
  157. make.width.mas_equalTo(SCREEN_W);
  158. make.top.mas_equalTo(0);
  159. make.height.mas_equalTo(curHeight);
  160. }];
  161. _leftTableView.didLongPressClick = ^{
  162. weakSelf.isEditType = YES;
  163. };
  164. _leftTableView.didClickSectionHeadViewRightButton = ^(NSInteger section) {
  165. [weakSelf didClikRightButInUploadTableVieFunBy:section];
  166. };
  167. _leftTableView.didNeedRefreshGetDatabaseFun = ^{
  168. [weakSelf RefreshUploadViewFun];
  169. };
  170. _midTableView = [[downloadFileRecordTableView alloc] init];
  171. _midTableView.tag = 101;
  172. [_uploadFileRecordBgScorllV addSubview:_midTableView];
  173. [_midTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  174. make.left.mas_equalTo(SCREEN_W*1.0);
  175. make.width.mas_equalTo(SCREEN_W);
  176. make.top.mas_equalTo(0);
  177. make.height.mas_equalTo(curHeight);
  178. }];
  179. _midTableView.didLongPressClick = ^{
  180. weakSelf.isEditType = YES;
  181. };
  182. _midTableView.didClickSectionHeadViewRightButton = ^(NSInteger section) {
  183. [weakSelf didClikRightButInDownloadTableVieFunBy:section];
  184. };
  185. _midTableView.didNeedRefreshGetDatabaseFun = ^{
  186. [weakSelf getDownloadDataInDatabaseFun:NO];
  187. };
  188. _rightTableView = [[backupsFilerecordTableView alloc] init];
  189. _rightTableView.tag = 102;
  190. [_uploadFileRecordBgScorllV addSubview:_rightTableView];
  191. [_rightTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  192. make.left.mas_equalTo(SCREEN_W*2.0);
  193. make.width.mas_equalTo(SCREEN_W);
  194. make.top.mas_equalTo(0);
  195. make.height.mas_equalTo(curHeight);
  196. }];
  197. _rightTableView.didLongPressClick = ^{
  198. // weakSelf.isEditType = YES;
  199. };
  200. //接收
  201. _curReceiveView = [[receiveView alloc] init];
  202. _curReceiveView.tag = 103;
  203. [_uploadFileRecordBgScorllV addSubview:_curReceiveView];
  204. [_curReceiveView mas_makeConstraints:^(MASConstraintMaker *make) {
  205. make.left.mas_equalTo(SCREEN_W*3.0);
  206. make.width.mas_equalTo(SCREEN_W);
  207. make.top.mas_equalTo(0);
  208. make.height.mas_equalTo(curHeight);
  209. }];
  210. _curReceiveView.didLongPressClick = ^{
  211. weakSelf.isEditType = YES;
  212. };
  213. _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*4.0, curHeight);
  214. // _leftHeadView = [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
  215. // _leftTableView.tableHeaderView = _leftHeadView;
  216. // _leftHeadView.didClickButFun = ^{
  217. // [weakSelf didClickAllSuspendInLoadingFun];
  218. // };
  219. //
  220. // _midHeadView = [[uploadFileRecordTableViewHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
  221. // _midTableView.tableHeaderView = _midHeadView;
  222. // _midHeadView.didClickButFun = ^{
  223. // [weakSelf didClickClearRecordInDoneFun];
  224. // };
  225. _leftButton = [[UIButton alloc] init];
  226. [_leftButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  227. _leftButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  228. _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  229. [_leftButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  230. _leftButton.tag = 1;
  231. [_leftButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  232. _leftButton.hidden = YES;
  233. [self.navBarBGView addSubview:_leftButton];
  234. [_leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
  235. make.width.mas_equalTo(80);
  236. make.left.mas_equalTo(15);
  237. make.height.mas_equalTo(self.backBtn.mas_height);
  238. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  239. }];
  240. _rightButton = [[UIButton alloc] init];
  241. [_rightButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  242. _rightButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  243. _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  244. [_rightButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  245. _rightButton.tag = 2;
  246. [_rightButton setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal];
  247. [_rightButton setTitle:NSLocalizedString(@"File_upload_cancel_select_all",nil) forState:UIControlStateSelected];
  248. _rightButton.hidden = YES;
  249. [self.navBarBGView addSubview:_rightButton];
  250. //多国语言适配
  251. NSString *languageCode = [NSLocale preferredLanguages][0];
  252. if([languageCode rangeOfString:@"ja-"].location != NSNotFound)
  253. {
  254. _rightButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
  255. _leftButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
  256. }
  257. [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  258. make.width.mas_equalTo(90);
  259. make.right.mas_equalTo(-15);
  260. make.height.mas_equalTo(self.backBtn.mas_height);
  261. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  262. }];
  263. _uploadFileRecordEditBottomV = [[uploadFileRecordEditBottomView alloc] init];
  264. _uploadFileRecordEditBottomV.hidden = YES;
  265. [self.view addSubview:_uploadFileRecordEditBottomV];
  266. [_uploadFileRecordEditBottomV mas_makeConstraints:^(MASConstraintMaker *make) {
  267. make.left.mas_equalTo(0);
  268. make.right.mas_equalTo(0);
  269. make.height.mas_equalTo(60 + safeArea);
  270. make.bottom.mas_equalTo(0);
  271. }];
  272. _uploadFileRecordEditBottomV.didClickButFun = ^{
  273. //[weakSelf.uploadFileRecordBodyV deleteModelOneByOneFun];
  274. [weakSelf didClickBottomDeleteFun];
  275. };
  276. }
  277. #pragma mark 底部删除点击
  278. -(void)didClickBottomDeleteFun
  279. {
  280. NSMutableArray *selectModelArr ;//= _leftTableView.selectModelArr;
  281. if(_selectIndex == 1){
  282. selectModelArr = _leftTableView.selectModelArr;
  283. }
  284. else if(_selectIndex == 2){
  285. selectModelArr = _midTableView.selectModelArr;
  286. }
  287. else if(_selectIndex == 3){
  288. return;
  289. }
  290. else if(_selectIndex == 4){
  291. selectModelArr = _curReceiveView.selectModelArr;
  292. }
  293. if(!selectModelArr || selectModelArr.count== 0){
  294. [[iToast makeText:NSLocalizedString(@"File_upload_Record_delete_noFile",nil)] show];
  295. return;
  296. }
  297. if(_selectIndex == 1){//上传相关特殊处理
  298. NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  299. NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  300. KWeakSelf
  301. ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  302. initWithTitle:titleStr
  303. msg:@""
  304. imageStr:@""
  305. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  306. okTitle:NSLocalizedString(@"other_confirm",nil)
  307. otherTitle:tipStr
  308. isOkBtnHighlight:YES
  309. didClickOk:^(BOOL isDeleteAll) {
  310. [weakSelf didClickDeleteOkButBy:isDeleteAll];
  311. } didClickCancel:^{
  312. }];
  313. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  314. [self presentViewController:curAlretVC animated:YES completion:^{
  315. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  316. }];
  317. }
  318. else{
  319. NSString *delTipTip = NSLocalizedString(@"box_receive_delete_msg",nil);
  320. /*弹窗提示二次确认*/
  321. KWeakSelf
  322. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  323. msg:delTipTip
  324. imageStr:@""
  325. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  326. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  327. didClickOk:^{
  328. [weakSelf didClickBottomDeleteFunAfterAleartFun];
  329. } didClickCancel:^{
  330. }];
  331. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  332. [self presentViewController:nextVC animated:YES completion:^{
  333. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  334. }];
  335. }
  336. }
  337. #pragma mark 选中上传任务的删除的处理
  338. - (void)didClickDeleteOkButBy:(BOOL)isDeleteAll
  339. {
  340. if(isDeleteAll){//删除云机上的文件
  341. [self delFileListFunWithData:_leftTableView.selectModelArr];
  342. }
  343. [self didClickBottomDeleteFunAfterAleartFun];
  344. }
  345. -(void)didClickBottomDeleteFunAfterAleartFun
  346. {
  347. [SVProgressHUD show];
  348. if(_selectIndex == 1){
  349. [_leftTableView deleteModelOneByOneFun];
  350. }
  351. else if(_selectIndex == 2){
  352. [_midTableView deleteModelOneByOneFun];
  353. }
  354. else if(_selectIndex == 3){
  355. //没有操作
  356. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  357. [SVProgressHUD dismiss];
  358. });
  359. }
  360. else if(_selectIndex == 4){
  361. [_curReceiveView deleteModelOneByOneFun];
  362. [SVProgressHUD dismiss];
  363. }
  364. }
  365. #pragma mark 头部点击 背景滚动
  366. - (void)didClickHeadFun:(NSInteger)index
  367. {
  368. //_uploadFileRecordBodyV.selectIndex = index;
  369. _selectIndex = index;
  370. _uploadFileRecordBgScorllV.contentOffset = CGPointMake(SCREEN_W *(index -1), 0);
  371. }
  372. - (void)didScorllBodyFun:(NSInteger)index
  373. {
  374. _uploadFileRecordheadV.selectIndex = index;
  375. _selectIndex = index;
  376. }
  377. #pragma mark 1.3版本UI修改后 上传文件列表的内容点击时间
  378. - (void)didClikRightButInUploadTableVieFunBy:(NSInteger)section
  379. {
  380. if(section == 0){
  381. [self didClickAllSuspendInLoadingFun];
  382. }
  383. else if(section == 1){//成功
  384. [self didClickClearRecordInDoneFun];
  385. }
  386. else if(section == 2){//失败
  387. [self didClickClearRecordInFailFun];
  388. }
  389. }
  390. #pragma mark 背景滚动代理
  391. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  392. {
  393. if(scrollView != _uploadFileRecordBgScorllV) return;
  394. CGFloat x = scrollView.contentOffset.x;
  395. NSInteger index = (x+1)/SCREEN_W;
  396. index += 1;//因为头部是从1开始的
  397. //HLog(@"index:%ld",index);
  398. [self didScorllBodyFun:index];
  399. }
  400. -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems
  401. {
  402. KWeakSelf
  403. mainBlock(^{
  404. weakSelf.didGetUploadDataType = YES;
  405. [weakSelf handleRemoveIndicator];
  406. });
  407. [self realGotoUploadFile:indexPathsForSelectedItems];
  408. }
  409. - (void)realGotoUploadFile:(NSMutableArray *)indexPathsForSelectedItems
  410. {
  411. KWeakSelf
  412. [[nasUploadFileManager shareInstance] handlTZAssetModelToUploadFileDataFunBy:indexPathsForSelectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  413. //NSMutableArray *arr1 = Arr;
  414. //[weakSelf setRecordBodyDataFunBy:arr1];
  415. //weakSelf.leftTableView.curDataArr = Arr[0];
  416. mainBlock(^{
  417. weakSelf.leftTableView.outSideDataArr = Arr;
  418. [weakSelf handleUploadingRightButFun:YES];
  419. });
  420. }];
  421. }
  422. #pragma mark 读取数据库数据
  423. - (void)getUploadDataInDatabaseFun
  424. {
  425. //查询是否为nas上传中
  426. BOOL isUploadingType = [nasMixUploadManager shareManager].isUploadIngType;
  427. //判断是否要重新拿数据
  428. BOOL isNeedRegetDataType = !isUploadingType;
  429. KWeakSelf
  430. [[nasUploadFileManager shareInstance] getDataInDatabaseFun:isNeedRegetDataType complete:^(NSMutableArray * _Nonnull Arr) {
  431. //[weakSelf setRecordBodyDataFunBy:Arr];
  432. weakSelf.didGetUploadDataType = YES;
  433. [weakSelf handleRemoveIndicator];
  434. if(!Arr ||Arr.count != 3){
  435. HLog(@"数据库出错\n\n\n");
  436. return;
  437. }
  438. NSMutableArray *curLoadIngArr = Arr[0];
  439. //不是上传视频和进来的 所以上传状态(上传中和等待)改为重新上传
  440. if(!weakSelf.isUploadingType && isNeedRegetDataType){
  441. //改为暂停
  442. // for (uploadFileDataModel * curModel in curLoadIngArr) {
  443. // curModel.curUploadStateType = uploadStateSuspend;
  444. // }
  445. //改为重新上传
  446. NSMutableArray *handleUploadArr = [NSMutableArray new];
  447. for (uploadFileDataModel * curModel in curLoadIngArr) {
  448. if(curModel.curUploadStateType != uploadStateSuspend)
  449. {
  450. [handleUploadArr addObject:curModel];
  451. }
  452. }
  453. if(handleUploadArr.count >0){
  454. //[[uploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
  455. [[nasUploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
  456. }
  457. }
  458. mainBlock(^{
  459. weakSelf.leftTableView.outSideDataArr = Arr;
  460. [weakSelf handleUploadingRightButFun:NO];
  461. });
  462. }];
  463. }
  464. - (void)getBackupsDatabaseFun
  465. {
  466. KWeakSelf
  467. [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
  468. mainBlock(^{
  469. weakSelf.didGetbackupsloadDataType = YES;
  470. [weakSelf handleRemoveIndicator];
  471. weakSelf.rightTableView.curDataArr = array;
  472. });
  473. }];
  474. }
  475. #pragma mark 读取数据库数据
  476. - (void)getDownloadDataInDatabaseFun:(BOOL)isRegetType
  477. {
  478. if(isRegetType){
  479. //查询是否为nas下载中
  480. BOOL isDownLoadIngType = [nasDownloadManager shareManager].isDownLoadIngType;
  481. //判断是否要重新拿数据
  482. isRegetType = !isDownLoadIngType;
  483. }
  484. KWeakSelf
  485. [[nasDownloadFileManager shareInstance] getDataInDatabaseFun:isRegetType complete:^(NSMutableArray * _Nonnull Arr) {
  486. weakSelf.didGetDownloadDataType = YES;
  487. [weakSelf handleRemoveIndicator];
  488. if(!Arr ||Arr.count != 3){
  489. HLog(@"数据库出错\n\n\n");
  490. return;
  491. }
  492. NSMutableArray *curLoadIngArr = Arr[0];
  493. //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  494. if(![nasDownloadManager shareManager].isDownLoadIngType && isRegetType){
  495. // for (couldPhoneFileModel * curModel in curLoadIngArr) {
  496. // curModel.curDownloadStateType = downloadStateSuspend;
  497. // }
  498. //改为重新下载
  499. NSMutableArray *handleDownloadArr = [NSMutableArray new];
  500. for (couldPhoneFileModel * curModel in curLoadIngArr) {
  501. if(curModel.curDownloadStateType != downloadStateSuspend)
  502. {
  503. [handleDownloadArr addObject:curModel];
  504. }
  505. }
  506. if(handleDownloadArr.count >0){
  507. [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:handleDownloadArr withAll:NO];
  508. }
  509. }
  510. mainBlock(^{
  511. weakSelf.midTableView.outSideDataArr = Arr;
  512. [weakSelf.midTableView reloadDataFun];
  513. [weakSelf handleDownloadingRightButFun];
  514. });
  515. }];
  516. }
  517. #pragma mark 处理上传中的 全部暂停等
  518. - (void)handleUploadingRightButFun:(BOOL)isUserUploadIngType
  519. {
  520. // if(_leftTableView.uploadingArr.count == 0){
  521. // //不处理
  522. // }
  523. // else{
  524. // NSMutableArray *upLoadingArr = [uploadFileManager shareInstance].fileModelDataArr;
  525. // BOOL isUploadIngType = [uploadFileManager shareInstance].isUploadIngType;
  526. //
  527. // if(!isUserUploadIngType
  528. // &&(!upLoadingArr ||upLoadingArr.count == 0 || !isUploadIngType)){//不是上传状态
  529. // _leftTableView.uploadingHeadView.rightButton.selected = YES;
  530. // }
  531. // else if(upLoadingArr.count == _leftTableView.uploadingArr.count){
  532. // _leftTableView.uploadingHeadView.rightButton.selected = NO;
  533. // }
  534. // else{
  535. // _leftTableView.uploadingHeadView.rightButton.selected = YES;
  536. // }
  537. // }
  538. }
  539. #pragma mark 处理下载中的 全部暂停等
  540. - (void)handleDownloadingRightButFun
  541. {
  542. if(_midTableView.downloadingArr.count == 0){
  543. //不处理
  544. }
  545. else{
  546. NSMutableArray *downloadingArr = [nasDownloadFileManager shareInstance].downLoadFileModelDataArr;
  547. BOOL isDownloadIngType = [nasDownloadManager shareManager].isDownLoadIngType;
  548. if(!downloadingArr ||downloadingArr.count == 0 || !isDownloadIngType){//不是下载状态
  549. _midTableView.downloadingHeadView.rightButton.selected = YES;
  550. }
  551. else if(downloadingArr.count == _midTableView.downloadingArr.count){
  552. _midTableView.downloadingHeadView.rightButton.selected = NO;
  553. }
  554. else{
  555. _midTableView.downloadingHeadView.rightButton.selected = YES;
  556. }
  557. }
  558. }
  559. - (void)uploadFileRefreshFun:(NSNotification*)not
  560. {
  561. uploadFileDataModel *uploadFileDataMod = [not object];
  562. //HLog(@"%@",uploadFileDataMod);
  563. uploadFileDataMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  564. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  565. //HLog(@"传输列表的上传任务:%@",uploadingArr);
  566. // for (int i=0; i<uploadingArr.count; i++) {
  567. // uploadFileDataModel*preModel = uploadingArr[i];
  568. // if(preModel.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  569. // [_leftTableView.uploadingArr replaceObjectAtIndex:i withObject:uploadFileDataMod];
  570. // break;
  571. // }
  572. // }
  573. if(uploadFileDataMod.curUploadStateType == uploadStateDone
  574. || uploadFileDataMod.curUploadStateType == uploadStateFail){
  575. [self RefreshUploadViewFun];
  576. }
  577. else{
  578. [_leftTableView RefreshAllDataFun];
  579. }
  580. }
  581. - (void)uploadFileSuspendAllFun:(NSNotification*)not
  582. {
  583. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  584. for (int i=0; i<uploadingArr.count; i++) {
  585. uploadFileDataModel*preModel = uploadingArr[i];
  586. if(preModel.curUploadStateType == uploadStateUploading
  587. ||preModel.curUploadStateType == uploadStateWait){
  588. preModel.curUploadStateType = uploadStateSuspend;
  589. //break;
  590. }
  591. }
  592. }
  593. #pragma mark 那上传那边的数据来更新页面
  594. - (void)RefreshUploadViewFun
  595. {
  596. KWeakSelf
  597. [[nasUploadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
  598. //[weakSelf setRecordBodyDataFunBy:Arr];
  599. if(!Arr ||Arr.count != 3){
  600. HLog(@"数据库出错\n\n\n");
  601. return;
  602. }
  603. mainBlock(^{
  604. weakSelf.leftTableView.outSideDataArr = Arr;
  605. //[weakSelf handleUploadingRightButFun];
  606. });
  607. }];
  608. }
  609. #pragma mark 按钮点击
  610. - (void)didClickButFun:(UIButton*)but
  611. {
  612. NSInteger tag = but.tag;
  613. if(tag == 1){
  614. self.isEditType = NO;
  615. //self.uploadFileRecordBodyV.isEditType = NO;
  616. if(_selectIndex == 1){
  617. self.leftTableView.isEditType = NO;
  618. }
  619. else if(_selectIndex == 2){
  620. self.midTableView.isEditType = NO;
  621. }
  622. else if(_selectIndex == 3){
  623. //self.rightTableView.isEditType = NO;
  624. }
  625. }
  626. else{
  627. //self.uploadFileRecordBodyV.isSelectAllType = YES;
  628. but.selected = !but.selected;
  629. BOOL curSelectAllType = but.selected;
  630. if(_selectIndex == 1){
  631. self.leftTableView.isSelectAllType = curSelectAllType;
  632. }
  633. else if(_selectIndex == 2){
  634. self.midTableView.isSelectAllType = curSelectAllType;
  635. }
  636. else if(_selectIndex == 3){
  637. //self.rightTableView.isSelectAllType = YES;
  638. }
  639. else if(_selectIndex == 4){
  640. self.curReceiveView.isSelectAllType = curSelectAllType;
  641. }
  642. }
  643. }
  644. -(void)setIsEditType:(BOOL)isEditType
  645. {
  646. _isEditType = isEditType;
  647. _leftButton.hidden = !isEditType;
  648. _rightButton.hidden = !isEditType;
  649. self.backBtn.hidden = isEditType;
  650. _uploadFileRecordEditBottomV.hidden = !isEditType;
  651. _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
  652. _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
  653. //_leftHeadView.rightButton.userInteractionEnabled = !isEditType;
  654. _curReceiveView.isEditType = isEditType;
  655. if(_isEditType){
  656. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15 - (60 + safeArea + AdaptTabHeight);
  657. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  658. make.left.mas_equalTo(0);
  659. make.right.mas_equalTo(0);
  660. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  661. make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top);
  662. }];
  663. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  664. make.left.mas_equalTo(SCREEN_W*0.0);
  665. make.width.mas_equalTo(SCREEN_W);
  666. make.top.mas_equalTo(0);
  667. make.height.mas_equalTo(curHeight);
  668. }];
  669. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  670. make.left.mas_equalTo(SCREEN_W*1.0);
  671. make.width.mas_equalTo(SCREEN_W);
  672. make.top.mas_equalTo(0);
  673. make.height.mas_equalTo(curHeight);
  674. }];
  675. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  676. make.left.mas_equalTo(SCREEN_W*2.0);
  677. make.width.mas_equalTo(SCREEN_W);
  678. make.top.mas_equalTo(0);
  679. make.height.mas_equalTo(curHeight);
  680. }];
  681. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  682. make.left.mas_equalTo(SCREEN_W*3.0);
  683. make.width.mas_equalTo(SCREEN_W);
  684. make.top.mas_equalTo(0);
  685. make.height.mas_equalTo(curHeight);
  686. }];
  687. }
  688. else{
  689. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  690. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  691. make.left.mas_equalTo(0);
  692. make.right.mas_equalTo(0);
  693. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  694. make.bottom.mas_equalTo(0);
  695. }];
  696. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  697. make.left.mas_equalTo(SCREEN_W*0.0);
  698. make.width.mas_equalTo(SCREEN_W);
  699. make.top.mas_equalTo(0);
  700. make.height.mas_equalTo(curHeight);
  701. }];
  702. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  703. make.left.mas_equalTo(SCREEN_W*1.0);
  704. make.width.mas_equalTo(SCREEN_W);
  705. make.top.mas_equalTo(0);
  706. make.height.mas_equalTo(curHeight);
  707. }];
  708. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  709. make.left.mas_equalTo(SCREEN_W*2.0);
  710. make.width.mas_equalTo(SCREEN_W);
  711. make.top.mas_equalTo(0);
  712. make.height.mas_equalTo(curHeight);
  713. }];
  714. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  715. make.left.mas_equalTo(SCREEN_W*3.0);
  716. make.width.mas_equalTo(SCREEN_W);
  717. make.top.mas_equalTo(0);
  718. make.height.mas_equalTo(curHeight);
  719. }];
  720. }
  721. }
  722. #pragma mark 点击上传中的全部暂停
  723. - (void)didClickAllSuspendInLoadingFun
  724. {
  725. _leftTableView.uploadingHeadView.rightButton.selected = !_leftTableView.uploadingHeadView.rightButton.selected;
  726. if(_leftTableView.uploadingHeadView.rightButton.selected){
  727. //[[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  728. [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  729. [_leftTableView reloadDataFun];
  730. }
  731. else{
  732. NSMutableArray *leftArr = _leftTableView.uploadingArr;
  733. //[[uploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  734. [[nasUploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  735. }
  736. }
  737. #pragma mark 点击上传成功的清空记录
  738. - (void)didClickClearRecordInDoneFun
  739. {
  740. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  741. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  742. //
  743. // KWeakSelf
  744. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  745. // initWithTitle:titleStr
  746. // msg:nil
  747. // imageStr:nil
  748. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  749. // okTitle:NSLocalizedString(@"other_confirm",nil)
  750. // otherTitle:tipStr
  751. // isOkBtnHighlight:YES
  752. // didClickOk:^(BOOL isDeleteAll) {
  753. // [weakSelf didClickClearAllRecordInUploadDoneFun:isDeleteAll];
  754. // } didClickCancel:^{
  755. //
  756. // }];
  757. //
  758. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  759. //
  760. // [self presentViewController:curAlretVC animated:YES completion:^{
  761. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  762. // }];
  763. /*弹窗提示二次确认*/
  764. KWeakSelf
  765. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  766. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  767. imageStr:@""
  768. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  769. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  770. didClickOk:^{
  771. [weakSelf ClearAllRecordInDoneFun];
  772. } didClickCancel:^{
  773. }];
  774. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  775. [self presentViewController:nextVC animated:YES completion:^{
  776. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  777. }];
  778. }
  779. #pragma mark 确认要删除上传完成的任务
  780. - (void)didClickClearAllRecordInUploadDoneFun:(BOOL)isDeleteAllType
  781. {
  782. if(isDeleteAllType){
  783. [self delFileListFunWithData:_leftTableView.uploadDoneArr];
  784. }
  785. [self ClearAllRecordInDoneFun];
  786. }
  787. - (void)ClearAllRecordInDoneFun
  788. {
  789. [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadDoneArr withDelCache:YES complete:^(BOOL isSuccess) {
  790. HLog(@"isSuccess:%d",isSuccess);
  791. if(isSuccess){
  792. [self->_leftTableView.uploadDoneArr removeAllObjects];
  793. [self->_leftTableView reloadDataFun];
  794. }
  795. }];
  796. }
  797. #pragma mark 点击上传失败的清空记录
  798. - (void)didClickClearRecordInFailFun
  799. {
  800. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  801. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  802. //
  803. // KWeakSelf
  804. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  805. // initWithTitle:titleStr
  806. // msg:nil
  807. // imageStr:nil
  808. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  809. // okTitle:NSLocalizedString(@"other_confirm",nil)
  810. // otherTitle:tipStr
  811. // isOkBtnHighlight:YES
  812. // didClickOk:^(BOOL isDeleteAll) {
  813. // [weakSelf didClickClearAllRecordInUploadFailFun:isDeleteAll];
  814. // } didClickCancel:^{
  815. //
  816. // }];
  817. //
  818. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  819. //
  820. // [self presentViewController:curAlretVC animated:YES completion:^{
  821. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  822. // }];
  823. /*弹窗提示二次确认*/
  824. KWeakSelf
  825. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  826. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  827. imageStr:@""
  828. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  829. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  830. didClickOk:^{
  831. [weakSelf ClearAllRecordInFailFun];
  832. } didClickCancel:^{
  833. }];
  834. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  835. [self presentViewController:nextVC animated:YES completion:^{
  836. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  837. }];
  838. }
  839. #pragma mark 确认要删除上传失败的任务
  840. - (void)didClickClearAllRecordInUploadFailFun:(BOOL)isDeleteAllType
  841. {
  842. if(isDeleteAllType){
  843. [self delFileListFunWithData:_leftTableView.uploadfailArr];
  844. }
  845. [self ClearAllRecordInFailFun];
  846. }
  847. - (void)ClearAllRecordInFailFun
  848. {
  849. [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadfailArr withDelCache:YES complete:^(BOOL isSuccess) {
  850. HLog(@"isSuccess:%d",isSuccess);
  851. if(isSuccess){
  852. [self->_leftTableView.uploadfailArr removeAllObjects];
  853. [self->_leftTableView reloadDataFun];
  854. }
  855. }];
  856. }
  857. -(void)backBtnPressed{
  858. //[super backBtnPressed];
  859. NSArray *vcArrs = self.navigationController.viewControllers;
  860. NSInteger count = vcArrs.count;
  861. UIViewController *vc = nil;
  862. if(count > 2){
  863. UIViewController *lastVC = vcArrs[count-2];
  864. if([lastVC isKindOfClass:[uploadImageOrVideoViewController class]]){
  865. vc = vcArrs[count-3];
  866. }
  867. }
  868. if(vc){
  869. [self.navigationController popToViewController:vc animated:YES];
  870. }
  871. else{
  872. [self.navigationController popViewControllerAnimated:YES];
  873. }
  874. }
  875. - (void)backupsFileRefreshFun:(NSNotification*)not
  876. {
  877. photosBackupsTaskModel *photosBackupsTaskMod = [not object];
  878. //HLog(@"%@",uploadFileDataMod);
  879. if(photosBackupsTaskMod.didBackupsOneFileType){
  880. photosBackupsTaskMod.curTimeInterval = 0;
  881. photosBackupsTaskMod.preTimeInterval = 0;
  882. }
  883. else{
  884. photosBackupsTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  885. }
  886. _rightTableView.photosBackupsIngTaskModel = photosBackupsTaskMod;
  887. }
  888. -(void)gotoDownloadFile:(NSMutableArray*)selectedItems
  889. {
  890. KWeakSelf
  891. [[nasDownloadFileManager shareInstance] addNasDownloadRecordFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  892. weakSelf.didGetDownloadDataType = YES;
  893. [weakSelf handleRemoveIndicator];
  894. if(!Arr ||Arr.count != 3){
  895. HLog(@"数据库出错\n\n\n");
  896. return;
  897. }
  898. //NSMutableArray *curLoadIngArr = Arr[0];
  899. mainBlock(^{
  900. weakSelf.midTableView.outSideDataArr = Arr;
  901. [weakSelf.midTableView reloadDataFun];
  902. //[weakSelf handleUploadingRightButFun];
  903. });
  904. }];
  905. // [[downloadManager shareInstance] handleCouldPhoneFileModelToDownloadFileDataFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  906. //
  907. // weakSelf.didGetDownloadDataType = YES;
  908. // [weakSelf handleRemoveIndicator];
  909. //
  910. // if(!Arr ||Arr.count != 3){
  911. // HLog(@"数据库出错\n\n\n");
  912. // return;
  913. // }
  914. //
  915. // //NSMutableArray *curLoadIngArr = Arr[0];
  916. //
  917. // mainBlock(^{
  918. // weakSelf.midTableView.outSideDataArr = Arr;
  919. // [weakSelf.midTableView reloadDataFun];
  920. // //[weakSelf handleUploadingRightButFun];
  921. // });
  922. // }];
  923. //处理数据埋点
  924. NSString * firstFileType = nil;
  925. BOOL isSameFileType = YES;
  926. for (couldPhoneFileModel*model in selectedItems) {
  927. if(!firstFileType){
  928. firstFileType = model.fileType;
  929. }
  930. else if(![firstFileType isEqualToString:model.fileType]){
  931. isSameFileType = NO;
  932. break;
  933. }
  934. }
  935. if(!isSameFileType){
  936. //数据埋点
  937. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  938. }
  939. else if([firstFileType containsString:@"jpg"]){
  940. //数据埋点
  941. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_download"];
  942. }
  943. else if([firstFileType isEqualToString:@"video"]){
  944. //数据埋点
  945. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_download"];
  946. }
  947. else if([firstFileType isEqualToString:@"audio"]){
  948. //数据埋点
  949. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_download"];
  950. }
  951. else{
  952. //数据埋点
  953. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  954. }
  955. }
  956. #pragma mark nas http下载完成
  957. - (void)downloadTaskFinishedNoti:(NSNotification *)notification
  958. {
  959. //customDownloadOperation *model = notification.object;
  960. //NSString *url = model.url;
  961. [self getDownloadDataInDatabaseFun:NO];
  962. }
  963. - (void)downloadFileRefreshFun:(NSNotification*)not
  964. {
  965. couldPhoneFileModel *downloadTaskMod = [not object];
  966. if(!downloadTaskMod){
  967. [_midTableView RefreshAllDataFun];
  968. return;
  969. }
  970. HLog(@"hhhhhhh1 %@ didDownloadBytes:%ld",downloadTaskMod.name,downloadTaskMod.didDownloadBytes);
  971. downloadTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  972. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  973. for (int i=0; i<downloadingArr.count; i++) {
  974. couldPhoneFileModel*preModel = downloadingArr[i];
  975. if(preModel.bg_id.integerValue == downloadTaskMod.bg_id.integerValue){
  976. [_midTableView.downloadingArr replaceObjectAtIndex:i withObject:downloadTaskMod];
  977. break;
  978. }
  979. }
  980. if(downloadTaskMod.curDownloadStateType == downloadStateDone
  981. ||downloadTaskMod.curDownloadStateType == downloadStateFail){
  982. [self getDownloadDataInDatabaseFun:NO];
  983. }
  984. else{
  985. [_midTableView RefreshAllDataFun];
  986. }
  987. }
  988. - (void)downloadFileSuspendAllFun:(NSNotification*)not
  989. {
  990. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  991. for (int i=0; i<downloadingArr.count; i++) {
  992. couldPhoneFileModel*preModel = downloadingArr[i];
  993. if(preModel.curDownloadStateType == downloadStateUploading
  994. ||preModel.curDownloadStateType == downloadStateWait){
  995. preModel.curDownloadStateType = downloadStateSuspend;
  996. //break;
  997. }
  998. }
  999. [_midTableView RefreshAllDataFun];
  1000. }
  1001. #pragma mark 1.3版本UI修改后 下载文件列表的头部点击事件
  1002. - (void)didClikRightButInDownloadTableVieFunBy:(NSInteger)section
  1003. {
  1004. if(section == 0){
  1005. [self didClickAllSuspendInDownLoadingFun];
  1006. }
  1007. else if(section == 1){//成功
  1008. [self didClickClearDownLoadRecordInDoneFun];
  1009. }
  1010. else if(section == 2){//失败
  1011. [self didClickClearRecordInDownLoadFailFun];
  1012. }
  1013. }
  1014. #pragma mark 点击下载中的全部暂停
  1015. - (void)didClickAllSuspendInDownLoadingFun
  1016. {
  1017. _midTableView.downloadingHeadView.rightButton.selected = !_midTableView.downloadingHeadView.rightButton.selected;
  1018. if(_midTableView.downloadingHeadView.rightButton.selected){
  1019. [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  1020. }
  1021. else{
  1022. NSMutableArray *leftArr = _midTableView.downloadingArr;
  1023. [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:leftArr withAll:YES];
  1024. }
  1025. }
  1026. #pragma mark 点击下载成功的清空记录
  1027. - (void)didClickClearDownLoadRecordInDoneFun
  1028. {
  1029. /*弹窗提示二次确认*/
  1030. KWeakSelf
  1031. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1032. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  1033. imageStr:@""
  1034. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1035. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1036. didClickOk:^{
  1037. [weakSelf ClearAllRecordInDownloadDoneFun];
  1038. } didClickCancel:^{
  1039. }];
  1040. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1041. [self presentViewController:nextVC animated:YES completion:^{
  1042. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1043. }];
  1044. }
  1045. - (void)ClearAllRecordInDownloadDoneFun
  1046. {
  1047. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
  1048. }
  1049. #pragma mark 点击下载失败的清空记录
  1050. - (void)didClickClearRecordInDownLoadFailFun
  1051. {
  1052. /*弹窗提示二次确认*/
  1053. KWeakSelf
  1054. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1055. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  1056. imageStr:@""
  1057. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1058. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1059. didClickOk:^{
  1060. [weakSelf ClearAllRecordInDownloadFailFun];
  1061. } didClickCancel:^{
  1062. }];
  1063. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1064. [self presentViewController:nextVC animated:YES completion:^{
  1065. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1066. }];
  1067. }
  1068. - (void)ClearAllRecordInDownloadFailFun
  1069. {
  1070. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
  1071. }
  1072. /**********************************接收相关******************************************/
  1073. - (void)setIsReceiveType:(NSInteger)isReceiveType
  1074. {
  1075. _isReceiveType = isReceiveType;
  1076. KWeakSelf
  1077. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1078. weakSelf.curReceiveView.isReceiveType = isReceiveType;
  1079. [weakSelf.curReceiveView getAllDataFun];
  1080. [weakSelf delayChangeUIFunWithIndex:4];
  1081. });
  1082. }
  1083. #pragma mark 删除云机文件数据
  1084. - (void)delFileListFunWithData:(NSArray*)delDataArr
  1085. {
  1086. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1087. if(delDataArr){
  1088. NSMutableArray*pathArr = [NSMutableArray new];
  1089. for (uploadFileDataModel *uploadFileDataMod in delDataArr) {
  1090. NSString *uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  1091. if(uploadDefaultPath && uploadDefaultPath.length > 0){
  1092. //判断最后一个是否是/
  1093. NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
  1094. if(![lastStr isEqualToString:@"/"]){
  1095. uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
  1096. }
  1097. NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,uploadFileDataMod.filename];
  1098. [pathArr addObject:savePath];
  1099. }
  1100. }
  1101. [paraDict setValue:pathArr forKey:@"path"];
  1102. }
  1103. //[self showNewIndicatorWithCanBack:YES canTouch:NO];
  1104. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1105. //KWeakSelf //@"delFile"
  1106. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1107. //[weakSelf removeNewIndicator];
  1108. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1109. if(model && model.status == 0){
  1110. //[[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1111. }
  1112. else{
  1113. }
  1114. } failure:^(NSError * _Nonnull error) {
  1115. //[weakSelf removeNewIndicator];
  1116. }];
  1117. }
  1118. @end