uploadFileRecordViewController.m 47 KB

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