uploadFileRecordViewController.m 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315
  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. NSString * firstFileType = nil;
  895. BOOL isSameFileType = YES;
  896. for (couldPhoneFileModel*model in selectedItems) {
  897. if(!firstFileType){
  898. firstFileType = model.fileType;
  899. }
  900. else if(![firstFileType isEqualToString:model.fileType]){
  901. isSameFileType = NO;
  902. break;
  903. }
  904. }
  905. if(!isSameFileType){
  906. //数据埋点
  907. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_udownload"];
  908. }
  909. else if([firstFileType isEqualToString:@"jpg"]){
  910. //数据埋点
  911. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_download"];
  912. }
  913. else if([firstFileType isEqualToString:@"video"]){
  914. //数据埋点
  915. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_download"];
  916. }
  917. else if([firstFileType isEqualToString:@"audio"]){
  918. //数据埋点
  919. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_download"];
  920. }
  921. else{
  922. //数据埋点
  923. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_udownload"];
  924. }
  925. }
  926. - (void)downloadFileRefreshFun:(NSNotification*)not
  927. {
  928. couldPhoneFileModel *downloadTaskMod = [not object];
  929. HLog(@"hhhhhhh1 %@ didDownloadBytes:%ld",downloadTaskMod.name,downloadTaskMod.didDownloadBytes);
  930. downloadTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  931. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  932. for (int i=0; i<downloadingArr.count; i++) {
  933. couldPhoneFileModel*preModel = downloadingArr[i];
  934. if(preModel.bg_id.integerValue == downloadTaskMod.bg_id.integerValue){
  935. [_midTableView.downloadingArr replaceObjectAtIndex:i withObject:downloadTaskMod];
  936. break;
  937. }
  938. }
  939. if(downloadTaskMod.curDownloadStateType == downloadStateDone
  940. ||downloadTaskMod.curDownloadStateType == downloadStateFail){
  941. [self getDownloadDataInDatabaseFun:NO];
  942. }
  943. else{
  944. [_midTableView RefreshAllDataFun];
  945. }
  946. }
  947. - (void)downloadFileSuspendAllFun:(NSNotification*)not
  948. {
  949. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  950. for (int i=0; i<downloadingArr.count; i++) {
  951. couldPhoneFileModel*preModel = downloadingArr[i];
  952. if(preModel.curDownloadStateType == downloadStateUploading
  953. ||preModel.curDownloadStateType == downloadStateWait){
  954. preModel.curDownloadStateType = downloadStateSuspend;
  955. //break;
  956. }
  957. }
  958. [_midTableView RefreshAllDataFun];
  959. }
  960. #pragma mark 1.3版本UI修改后 下载文件列表的头部点击事件
  961. - (void)didClikRightButInDownloadTableVieFunBy:(NSInteger)section
  962. {
  963. if(section == 0){
  964. [self didClickAllSuspendInDownLoadingFun];
  965. }
  966. else if(section == 1){//成功
  967. [self didClickClearDownLoadRecordInDoneFun];
  968. }
  969. else if(section == 2){//失败
  970. [self didClickClearRecordInDownLoadFailFun];
  971. }
  972. }
  973. #pragma mark 点击下载中的全部暂停
  974. - (void)didClickAllSuspendInDownLoadingFun
  975. {
  976. _midTableView.downloadingHeadView.rightButton.selected = !_midTableView.downloadingHeadView.rightButton.selected;
  977. if(_midTableView.downloadingHeadView.rightButton.selected){
  978. [[downloadManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  979. }
  980. else{
  981. NSMutableArray *leftArr = _midTableView.downloadingArr;
  982. [[downloadManager shareInstance] reDownloadFileFunBy:leftArr withAll:YES];
  983. }
  984. }
  985. #pragma mark 点击下载成功的清空记录
  986. - (void)didClickClearDownLoadRecordInDoneFun
  987. {
  988. /*弹窗提示二次确认*/
  989. KWeakSelf
  990. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  991. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  992. imageStr:nil
  993. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  994. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  995. didClickOk:^{
  996. [weakSelf ClearAllRecordInDownloadDoneFun];
  997. } didClickCancel:^{
  998. }];
  999. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1000. [self presentViewController:nextVC animated:YES completion:^{
  1001. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1002. }];
  1003. }
  1004. - (void)ClearAllRecordInDownloadDoneFun
  1005. {
  1006. [[downloadManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
  1007. }
  1008. #pragma mark 点击下载失败的清空记录
  1009. - (void)didClickClearRecordInDownLoadFailFun
  1010. {
  1011. /*弹窗提示二次确认*/
  1012. KWeakSelf
  1013. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1014. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  1015. imageStr:nil
  1016. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1017. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1018. didClickOk:^{
  1019. [weakSelf ClearAllRecordInDownloadFailFun];
  1020. } didClickCancel:^{
  1021. }];
  1022. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1023. [self presentViewController:nextVC animated:YES completion:^{
  1024. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1025. }];
  1026. }
  1027. - (void)ClearAllRecordInDownloadFailFun
  1028. {
  1029. [[downloadManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
  1030. }
  1031. /**********************************接收相关******************************************/
  1032. - (void)setIsReceiveType:(NSInteger)isReceiveType
  1033. {
  1034. _isReceiveType = isReceiveType;
  1035. KWeakSelf
  1036. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1037. weakSelf.curReceiveView.isReceiveType = isReceiveType;
  1038. [weakSelf.curReceiveView getAllDataFun];
  1039. [weakSelf delayChangeUIFunWithIndex:4];
  1040. });
  1041. }
  1042. #pragma mark 删除云机文件数据
  1043. - (void)delFileListFunWithData:(NSArray*)delDataArr
  1044. {
  1045. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1046. if(delDataArr){
  1047. NSMutableArray*pathArr = [NSMutableArray new];
  1048. for (uploadFileDataModel *uploadFileDataMod in delDataArr) {
  1049. NSString *uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  1050. if(uploadDefaultPath && uploadDefaultPath.length > 0){
  1051. //判断最后一个是否是/
  1052. NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
  1053. if(![lastStr isEqualToString:@"/"]){
  1054. uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
  1055. }
  1056. NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,uploadFileDataMod.filename];
  1057. [pathArr addObject:savePath];
  1058. }
  1059. }
  1060. [paraDict setValue:pathArr forKey:@"path"];
  1061. }
  1062. //[self showNewIndicatorWithCanBack:YES canTouch:NO];
  1063. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1064. KWeakSelf //@"delFile"
  1065. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1066. //[weakSelf removeNewIndicator];
  1067. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1068. if(model && model.status == 0){
  1069. //[[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1070. }
  1071. else{
  1072. }
  1073. } failure:^(NSError * _Nonnull error) {
  1074. //[weakSelf removeNewIndicator];
  1075. }];
  1076. }
  1077. @end