uploadFileRecordViewController.m 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319
  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 + AdaptTabHeight);
  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. NSArray *vcArrs = self.navigationController.viewControllers;
  848. NSInteger count = vcArrs.count;
  849. UIViewController *vc = nil;
  850. if(count > 2){
  851. UIViewController *lastVC = vcArrs[count-2];
  852. if([lastVC isKindOfClass:[uploadImageOrVideoViewController class]]){
  853. vc = vcArrs[count-3];
  854. }
  855. }
  856. if(vc){
  857. [self.navigationController popToViewController:vc animated:YES];
  858. }
  859. else{
  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_download"];
  908. }
  909. else if([firstFileType containsString:@"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_download"];
  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