uploadFileRecordViewController.m 46 KB

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