uploadFileRecordViewController.m 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. //
  2. // uoloadFileRecordViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/13.
  6. //
  7. #import "uploadFileRecordViewController.h"
  8. #import "uploadFileManager.h"
  9. #import "uploadFileDataModel.h"
  10. #import "uploadFileRecordheadView.h"
  11. //#import "uploadFileRecordBodyView.h"
  12. #import "uploadFileRecordEditBottomView.h"
  13. #import "uploadFileRecordBgScorllView.h"
  14. #import "uploadFileRecordTableView.h"
  15. #import "uploadFileRecordTableViewHeadView.h"
  16. #import "ComontAlretViewController.h"
  17. #import "backupsFilerecordTableView.h"
  18. #import "photosBackupsTaskModel.h"
  19. //#import "downloadManager.h"
  20. #import "downloadFileRecordTableView.h"
  21. #import "MySetViewController.h"
  22. #import "receiveView.h"
  23. #import "ComontAlretDeleteTypeViewController.h"
  24. @interface uploadFileRecordViewController ()<UIScrollViewDelegate,UIDocumentPickerDelegate>
  25. //选中的项
  26. @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
  27. @property (nonatomic, strong) uploadFileRecordheadView *uploadFileRecordheadV;
  28. @property (nonatomic, strong) uploadFileRecordBgScorllView *uploadFileRecordBgScorllV;
  29. @property (nonatomic, strong) uploadFileRecordTableView *leftTableView;
  30. @property (nonatomic, strong) downloadFileRecordTableView *midTableView;
  31. @property (nonatomic, strong) backupsFilerecordTableView *rightTableView;
  32. @property (nonatomic, strong) receiveView *curReceiveView;
  33. //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView;
  34. //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *midHeadView;
  35. //@property (nonatomic, strong) NSMutableArray *allDataArr;
  36. @property (nonatomic, strong) UIButton *leftButton;
  37. @property (nonatomic, strong) UIButton *rightButton;
  38. @property (nonatomic, strong) uploadFileRecordEditBottomView *uploadFileRecordEditBottomV;
  39. @property (nonatomic,assign) BOOL isEditType;
  40. @property(nonatomic,assign) NSInteger selectIndex;// 从1开始
  41. @property (nonatomic,assign) BOOL didGetUploadDataType;
  42. @property (nonatomic,assign) BOOL didGetDownloadDataType;
  43. @property (nonatomic,assign) BOOL didGetbackupsloadDataType;
  44. @property (nonatomic, copy) NSString *h5ShareDownloadUrl;
  45. @end
  46. @implementation uploadFileRecordViewController
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. // Do any additional setup after loading the view.
  50. //[self.view setBackgroundColor:HWF5F7FAColor];
  51. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileRefreshFun:) name:uploadFileRefreshNotification object:nil];
  52. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileSuspendAllFun:) name:uploadFileSuspendAllNotification object:nil];
  53. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backupsFileRefreshFun:) name:backupsFileRefreshNotification object:nil];
  54. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileRefreshFun:) name:downloadFileRefreshNotification object:nil];
  55. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadFileSuspendAllFun:) name:downloadFileSuspendAllNotification object:nil];
  56. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskFinishedNotification object:nil];
  57. [self.view setBackgroundColor:[UIColor whiteColor]];
  58. self.titleLabel.text = NSLocalizedString(@"my_set_no_File_Transfer_List",nil) ;
  59. [self.toolBar setHidden:YES];
  60. [self.navigationBar setHidden:YES];
  61. [self.navBarBGView setHidden:NO];
  62. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  63. [self initbaseUIFun];
  64. //数据埋点
  65. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Transmission_record"];
  66. }
  67. - (void)viewWillAppear:(BOOL)animated
  68. {
  69. [super viewWillAppear:animated];
  70. if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]){
  71. mainBlock(^{
  72. [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
  73. });
  74. // [self.navigationController popViewControllerAnimated:YES];
  75. // return;
  76. }
  77. [self getAllDataFun];
  78. }
  79. #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. [[nasDownloadFileManager 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:@""
  299. imageStr:@""
  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:@""
  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. [[nasUploadFileManager 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. [[nasUploadFileManager 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. [[nasUploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
  447. }
  448. }
  449. mainBlock(^{
  450. weakSelf.leftTableView.outSideDataArr = Arr;
  451. [weakSelf handleUploadingRightButFun:NO];
  452. });
  453. }];
  454. }
  455. - (void)getBackupsDatabaseFun
  456. {
  457. KWeakSelf
  458. [photosBackupsTaskModel bg_findAsync:backups_photos_tableName limit:1 orderBy:nil desc:YES complete:^(NSArray * _Nullable array) {
  459. mainBlock(^{
  460. weakSelf.didGetbackupsloadDataType = YES;
  461. [weakSelf handleRemoveIndicator];
  462. weakSelf.rightTableView.curDataArr = array;
  463. });
  464. }];
  465. }
  466. #pragma mark 读取数据库数据
  467. - (void)getDownloadDataInDatabaseFun:(BOOL)isRegetType
  468. {
  469. KWeakSelf
  470. [[nasDownloadFileManager shareInstance] getDataInDatabaseFun:isRegetType complete:^(NSMutableArray * _Nonnull Arr) {
  471. weakSelf.didGetDownloadDataType = YES;
  472. [weakSelf handleRemoveIndicator];
  473. if(!Arr ||Arr.count != 3){
  474. HLog(@"数据库出错\n\n\n");
  475. return;
  476. }
  477. NSMutableArray *curLoadIngArr = Arr[0];
  478. //不是上传视频和进来的 所以上传状态(上传中和等待)改为暂停
  479. if(![nasDownloadManager shareManager].isDownLoadIngType){
  480. // for (couldPhoneFileModel * curModel in curLoadIngArr) {
  481. // curModel.curDownloadStateType = downloadStateSuspend;
  482. // }
  483. //改为重新下载
  484. NSMutableArray *handleDownloadArr = [NSMutableArray new];
  485. for (couldPhoneFileModel * curModel in curLoadIngArr) {
  486. if(curModel.curDownloadStateType != downloadStateSuspend)
  487. {
  488. [handleDownloadArr addObject:curModel];
  489. }
  490. }
  491. if(handleDownloadArr.count >0){
  492. [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:handleDownloadArr withAll:NO];
  493. }
  494. }
  495. mainBlock(^{
  496. weakSelf.midTableView.outSideDataArr = Arr;
  497. [weakSelf.midTableView reloadDataFun];
  498. [weakSelf handleDownloadingRightButFun];
  499. });
  500. }];
  501. }
  502. #pragma mark 处理上传中的 全部暂停等
  503. - (void)handleUploadingRightButFun:(BOOL)isUserUploadIngType
  504. {
  505. if(_leftTableView.uploadingArr.count == 0){
  506. //不处理
  507. }
  508. else{
  509. NSMutableArray *upLoadingArr = [uploadFileManager shareInstance].fileModelDataArr;
  510. BOOL isUploadIngType = [uploadFileManager shareInstance].isUploadIngType;
  511. if(!isUserUploadIngType
  512. &&(!upLoadingArr ||upLoadingArr.count == 0 || !isUploadIngType)){//不是上传状态
  513. _leftTableView.uploadingHeadView.rightButton.selected = YES;
  514. }
  515. else if(upLoadingArr.count == _leftTableView.uploadingArr.count){
  516. _leftTableView.uploadingHeadView.rightButton.selected = NO;
  517. }
  518. else{
  519. _leftTableView.uploadingHeadView.rightButton.selected = YES;
  520. }
  521. }
  522. }
  523. #pragma mark 处理下载中的 全部暂停等
  524. - (void)handleDownloadingRightButFun
  525. {
  526. if(_midTableView.downloadingArr.count == 0){
  527. //不处理
  528. }
  529. else{
  530. NSMutableArray *downloadingArr = [nasDownloadFileManager shareInstance].downLoadFileModelDataArr;
  531. BOOL isDownloadIngType = [nasDownloadManager shareManager].isDownLoadIngType;
  532. if(!downloadingArr ||downloadingArr.count == 0 || !isDownloadIngType){//不是下载状态
  533. _midTableView.downloadingHeadView.rightButton.selected = YES;
  534. }
  535. else if(downloadingArr.count == _midTableView.downloadingArr.count){
  536. _midTableView.downloadingHeadView.rightButton.selected = NO;
  537. }
  538. else{
  539. _midTableView.downloadingHeadView.rightButton.selected = YES;
  540. }
  541. }
  542. }
  543. - (void)uploadFileRefreshFun:(NSNotification*)not
  544. {
  545. uploadFileDataModel *uploadFileDataMod = [not object];
  546. //HLog(@"%@",uploadFileDataMod);
  547. uploadFileDataMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  548. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  549. //HLog(@"传输列表的上传任务:%@",uploadingArr);
  550. for (int i=0; i<uploadingArr.count; i++) {
  551. uploadFileDataModel*preModel = uploadingArr[i];
  552. if(preModel.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  553. [_leftTableView.uploadingArr replaceObjectAtIndex:i withObject:uploadFileDataMod];
  554. break;
  555. }
  556. }
  557. if(uploadFileDataMod.curUploadStateType == uploadStateDone
  558. || uploadFileDataMod.curUploadStateType == uploadStateFail){
  559. [self RefreshUploadViewFun];
  560. }
  561. else{
  562. [_leftTableView RefreshAllDataFun];
  563. }
  564. }
  565. - (void)uploadFileSuspendAllFun:(NSNotification*)not
  566. {
  567. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  568. for (int i=0; i<uploadingArr.count; i++) {
  569. uploadFileDataModel*preModel = uploadingArr[i];
  570. if(preModel.curUploadStateType == uploadStateUploading
  571. ||preModel.curUploadStateType == uploadStateWait){
  572. preModel.curUploadStateType = uploadStateSuspend;
  573. //break;
  574. }
  575. }
  576. }
  577. #pragma mark 那上传那边的数据来更新页面
  578. - (void)RefreshUploadViewFun
  579. {
  580. KWeakSelf
  581. [[nasUploadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
  582. //[weakSelf setRecordBodyDataFunBy:Arr];
  583. if(!Arr ||Arr.count != 3){
  584. HLog(@"数据库出错\n\n\n");
  585. return;
  586. }
  587. mainBlock(^{
  588. weakSelf.leftTableView.outSideDataArr = Arr;
  589. //[weakSelf handleUploadingRightButFun];
  590. });
  591. }];
  592. }
  593. #pragma mark 按钮点击
  594. - (void)didClickButFun:(UIButton*)but
  595. {
  596. NSInteger tag = but.tag;
  597. if(tag == 1){
  598. self.isEditType = NO;
  599. //self.uploadFileRecordBodyV.isEditType = NO;
  600. if(_selectIndex == 1){
  601. self.leftTableView.isEditType = NO;
  602. }
  603. else if(_selectIndex == 2){
  604. self.midTableView.isEditType = NO;
  605. }
  606. else if(_selectIndex == 3){
  607. //self.rightTableView.isEditType = NO;
  608. }
  609. }
  610. else{
  611. //self.uploadFileRecordBodyV.isSelectAllType = YES;
  612. but.selected = !but.selected;
  613. BOOL curSelectAllType = but.selected;
  614. if(_selectIndex == 1){
  615. self.leftTableView.isSelectAllType = curSelectAllType;
  616. }
  617. else if(_selectIndex == 2){
  618. self.midTableView.isSelectAllType = curSelectAllType;
  619. }
  620. else if(_selectIndex == 3){
  621. //self.rightTableView.isSelectAllType = YES;
  622. }
  623. else if(_selectIndex == 4){
  624. self.curReceiveView.isSelectAllType = curSelectAllType;
  625. }
  626. }
  627. }
  628. -(void)setIsEditType:(BOOL)isEditType
  629. {
  630. _isEditType = isEditType;
  631. _leftButton.hidden = !isEditType;
  632. _rightButton.hidden = !isEditType;
  633. self.backBtn.hidden = isEditType;
  634. _uploadFileRecordEditBottomV.hidden = !isEditType;
  635. _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
  636. _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
  637. //_leftHeadView.rightButton.userInteractionEnabled = !isEditType;
  638. _curReceiveView.isEditType = isEditType;
  639. if(_isEditType){
  640. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15 - (60 + safeArea + AdaptTabHeight);
  641. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  642. make.left.mas_equalTo(0);
  643. make.right.mas_equalTo(0);
  644. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  645. make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top);
  646. }];
  647. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  648. make.left.mas_equalTo(SCREEN_W*0.0);
  649. make.width.mas_equalTo(SCREEN_W);
  650. make.top.mas_equalTo(0);
  651. make.height.mas_equalTo(curHeight);
  652. }];
  653. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  654. make.left.mas_equalTo(SCREEN_W*1.0);
  655. make.width.mas_equalTo(SCREEN_W);
  656. make.top.mas_equalTo(0);
  657. make.height.mas_equalTo(curHeight);
  658. }];
  659. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  660. make.left.mas_equalTo(SCREEN_W*2.0);
  661. make.width.mas_equalTo(SCREEN_W);
  662. make.top.mas_equalTo(0);
  663. make.height.mas_equalTo(curHeight);
  664. }];
  665. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  666. make.left.mas_equalTo(SCREEN_W*3.0);
  667. make.width.mas_equalTo(SCREEN_W);
  668. make.top.mas_equalTo(0);
  669. make.height.mas_equalTo(curHeight);
  670. }];
  671. }
  672. else{
  673. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  674. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  675. make.left.mas_equalTo(0);
  676. make.right.mas_equalTo(0);
  677. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  678. make.bottom.mas_equalTo(0);
  679. }];
  680. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  681. make.left.mas_equalTo(SCREEN_W*0.0);
  682. make.width.mas_equalTo(SCREEN_W);
  683. make.top.mas_equalTo(0);
  684. make.height.mas_equalTo(curHeight);
  685. }];
  686. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  687. make.left.mas_equalTo(SCREEN_W*1.0);
  688. make.width.mas_equalTo(SCREEN_W);
  689. make.top.mas_equalTo(0);
  690. make.height.mas_equalTo(curHeight);
  691. }];
  692. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  693. make.left.mas_equalTo(SCREEN_W*2.0);
  694. make.width.mas_equalTo(SCREEN_W);
  695. make.top.mas_equalTo(0);
  696. make.height.mas_equalTo(curHeight);
  697. }];
  698. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  699. make.left.mas_equalTo(SCREEN_W*3.0);
  700. make.width.mas_equalTo(SCREEN_W);
  701. make.top.mas_equalTo(0);
  702. make.height.mas_equalTo(curHeight);
  703. }];
  704. }
  705. }
  706. #pragma mark 点击上传中的全部暂停
  707. - (void)didClickAllSuspendInLoadingFun
  708. {
  709. _leftTableView.uploadingHeadView.rightButton.selected = !_leftTableView.uploadingHeadView.rightButton.selected;
  710. if(_leftTableView.uploadingHeadView.rightButton.selected){
  711. //[[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  712. [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  713. [_leftTableView reloadDataFun];
  714. }
  715. else{
  716. NSMutableArray *leftArr = _leftTableView.uploadingArr;
  717. //[[uploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  718. [[nasUploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  719. }
  720. }
  721. #pragma mark 点击上传成功的清空记录
  722. - (void)didClickClearRecordInDoneFun
  723. {
  724. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  725. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  726. //
  727. // KWeakSelf
  728. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  729. // initWithTitle:titleStr
  730. // msg:nil
  731. // imageStr:nil
  732. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  733. // okTitle:NSLocalizedString(@"other_confirm",nil)
  734. // otherTitle:tipStr
  735. // isOkBtnHighlight:YES
  736. // didClickOk:^(BOOL isDeleteAll) {
  737. // [weakSelf didClickClearAllRecordInUploadDoneFun:isDeleteAll];
  738. // } didClickCancel:^{
  739. //
  740. // }];
  741. //
  742. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  743. //
  744. // [self presentViewController:curAlretVC animated:YES completion:^{
  745. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  746. // }];
  747. /*弹窗提示二次确认*/
  748. KWeakSelf
  749. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  750. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  751. imageStr:@""
  752. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  753. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  754. didClickOk:^{
  755. [weakSelf ClearAllRecordInDoneFun];
  756. } didClickCancel:^{
  757. }];
  758. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  759. [self presentViewController:nextVC animated:YES completion:^{
  760. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  761. }];
  762. }
  763. #pragma mark 确认要删除上传完成的任务
  764. - (void)didClickClearAllRecordInUploadDoneFun:(BOOL)isDeleteAllType
  765. {
  766. if(isDeleteAllType){
  767. [self delFileListFunWithData:_leftTableView.uploadDoneArr];
  768. }
  769. [self ClearAllRecordInDoneFun];
  770. }
  771. - (void)ClearAllRecordInDoneFun
  772. {
  773. [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadDoneArr withDelCache:YES complete:^(BOOL isSuccess) {
  774. HLog(@"isSuccess:%d",isSuccess);
  775. if(isSuccess){
  776. [self->_leftTableView.uploadDoneArr removeAllObjects];
  777. [self->_leftTableView reloadDataFun];
  778. }
  779. }];
  780. }
  781. #pragma mark 点击上传失败的清空记录
  782. - (void)didClickClearRecordInFailFun
  783. {
  784. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  785. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  786. //
  787. // KWeakSelf
  788. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  789. // initWithTitle:titleStr
  790. // msg:nil
  791. // imageStr:nil
  792. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  793. // okTitle:NSLocalizedString(@"other_confirm",nil)
  794. // otherTitle:tipStr
  795. // isOkBtnHighlight:YES
  796. // didClickOk:^(BOOL isDeleteAll) {
  797. // [weakSelf didClickClearAllRecordInUploadFailFun:isDeleteAll];
  798. // } didClickCancel:^{
  799. //
  800. // }];
  801. //
  802. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  803. //
  804. // [self presentViewController:curAlretVC animated:YES completion:^{
  805. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  806. // }];
  807. /*弹窗提示二次确认*/
  808. KWeakSelf
  809. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  810. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  811. imageStr:@""
  812. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  813. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  814. didClickOk:^{
  815. [weakSelf ClearAllRecordInFailFun];
  816. } didClickCancel:^{
  817. }];
  818. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  819. [self presentViewController:nextVC animated:YES completion:^{
  820. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  821. }];
  822. }
  823. #pragma mark 确认要删除上传失败的任务
  824. - (void)didClickClearAllRecordInUploadFailFun:(BOOL)isDeleteAllType
  825. {
  826. if(isDeleteAllType){
  827. [self delFileListFunWithData:_leftTableView.uploadfailArr];
  828. }
  829. [self ClearAllRecordInFailFun];
  830. }
  831. - (void)ClearAllRecordInFailFun
  832. {
  833. [[uploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadfailArr withDelCache:YES complete:^(BOOL isSuccess) {
  834. HLog(@"isSuccess:%d",isSuccess);
  835. if(isSuccess){
  836. [self->_leftTableView.uploadfailArr removeAllObjects];
  837. [self->_leftTableView reloadDataFun];
  838. }
  839. }];
  840. }
  841. -(void)backBtnPressed{
  842. //[super backBtnPressed];
  843. NSArray *vcArrs = self.navigationController.viewControllers;
  844. NSInteger count = vcArrs.count;
  845. UIViewController *vc = nil;
  846. if(count > 2){
  847. UIViewController *lastVC = vcArrs[count-2];
  848. if([lastVC isKindOfClass:[uploadImageOrVideoViewController class]]){
  849. vc = vcArrs[count-3];
  850. }
  851. }
  852. if(vc){
  853. [self.navigationController popToViewController:vc animated:YES];
  854. }
  855. else{
  856. [self.navigationController popViewControllerAnimated:YES];
  857. }
  858. }
  859. - (void)backupsFileRefreshFun:(NSNotification*)not
  860. {
  861. photosBackupsTaskModel *photosBackupsTaskMod = [not object];
  862. //HLog(@"%@",uploadFileDataMod);
  863. if(photosBackupsTaskMod.didBackupsOneFileType){
  864. photosBackupsTaskMod.curTimeInterval = 0;
  865. photosBackupsTaskMod.preTimeInterval = 0;
  866. }
  867. else{
  868. photosBackupsTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  869. }
  870. _rightTableView.photosBackupsIngTaskModel = photosBackupsTaskMod;
  871. }
  872. -(void)gotoDownloadFile:(NSMutableArray*)selectedItems
  873. {
  874. KWeakSelf
  875. [[nasDownloadFileManager shareInstance] addNasDownloadRecordFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  876. weakSelf.didGetDownloadDataType = YES;
  877. [weakSelf handleRemoveIndicator];
  878. if(!Arr ||Arr.count != 3){
  879. HLog(@"数据库出错\n\n\n");
  880. return;
  881. }
  882. //NSMutableArray *curLoadIngArr = Arr[0];
  883. mainBlock(^{
  884. weakSelf.midTableView.outSideDataArr = Arr;
  885. [weakSelf.midTableView reloadDataFun];
  886. //[weakSelf handleUploadingRightButFun];
  887. });
  888. }];
  889. // [[downloadManager shareInstance] handleCouldPhoneFileModelToDownloadFileDataFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  890. //
  891. // weakSelf.didGetDownloadDataType = YES;
  892. // [weakSelf handleRemoveIndicator];
  893. //
  894. // if(!Arr ||Arr.count != 3){
  895. // HLog(@"数据库出错\n\n\n");
  896. // return;
  897. // }
  898. //
  899. // //NSMutableArray *curLoadIngArr = Arr[0];
  900. //
  901. // mainBlock(^{
  902. // weakSelf.midTableView.outSideDataArr = Arr;
  903. // [weakSelf.midTableView reloadDataFun];
  904. // //[weakSelf handleUploadingRightButFun];
  905. // });
  906. // }];
  907. //处理数据埋点
  908. NSString * firstFileType = nil;
  909. BOOL isSameFileType = YES;
  910. for (couldPhoneFileModel*model in selectedItems) {
  911. if(!firstFileType){
  912. firstFileType = model.fileType;
  913. }
  914. else if(![firstFileType isEqualToString:model.fileType]){
  915. isSameFileType = NO;
  916. break;
  917. }
  918. }
  919. if(!isSameFileType){
  920. //数据埋点
  921. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  922. }
  923. else if([firstFileType containsString:@"jpg"]){
  924. //数据埋点
  925. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_download"];
  926. }
  927. else if([firstFileType isEqualToString:@"video"]){
  928. //数据埋点
  929. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_download"];
  930. }
  931. else if([firstFileType isEqualToString:@"audio"]){
  932. //数据埋点
  933. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_download"];
  934. }
  935. else{
  936. //数据埋点
  937. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  938. }
  939. }
  940. #pragma mark nas http下载完成
  941. - (void)downloadTaskFinishedNoti:(NSNotification *)notification
  942. {
  943. //customDownloadOperation *model = notification.object;
  944. //NSString *url = model.url;
  945. [self getDownloadDataInDatabaseFun:NO];
  946. }
  947. - (void)downloadFileRefreshFun:(NSNotification*)not
  948. {
  949. couldPhoneFileModel *downloadTaskMod = [not object];
  950. if(!downloadTaskMod){
  951. [_midTableView RefreshAllDataFun];
  952. return;
  953. }
  954. HLog(@"hhhhhhh1 %@ didDownloadBytes:%ld",downloadTaskMod.name,downloadTaskMod.didDownloadBytes);
  955. downloadTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  956. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  957. for (int i=0; i<downloadingArr.count; i++) {
  958. couldPhoneFileModel*preModel = downloadingArr[i];
  959. if(preModel.bg_id.integerValue == downloadTaskMod.bg_id.integerValue){
  960. [_midTableView.downloadingArr replaceObjectAtIndex:i withObject:downloadTaskMod];
  961. break;
  962. }
  963. }
  964. if(downloadTaskMod.curDownloadStateType == downloadStateDone
  965. ||downloadTaskMod.curDownloadStateType == downloadStateFail){
  966. [self getDownloadDataInDatabaseFun:NO];
  967. }
  968. else{
  969. [_midTableView RefreshAllDataFun];
  970. }
  971. }
  972. - (void)downloadFileSuspendAllFun:(NSNotification*)not
  973. {
  974. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  975. for (int i=0; i<downloadingArr.count; i++) {
  976. couldPhoneFileModel*preModel = downloadingArr[i];
  977. if(preModel.curDownloadStateType == downloadStateUploading
  978. ||preModel.curDownloadStateType == downloadStateWait){
  979. preModel.curDownloadStateType = downloadStateSuspend;
  980. //break;
  981. }
  982. }
  983. [_midTableView RefreshAllDataFun];
  984. }
  985. #pragma mark 1.3版本UI修改后 下载文件列表的头部点击事件
  986. - (void)didClikRightButInDownloadTableVieFunBy:(NSInteger)section
  987. {
  988. if(section == 0){
  989. [self didClickAllSuspendInDownLoadingFun];
  990. }
  991. else if(section == 1){//成功
  992. [self didClickClearDownLoadRecordInDoneFun];
  993. }
  994. else if(section == 2){//失败
  995. [self didClickClearRecordInDownLoadFailFun];
  996. }
  997. }
  998. #pragma mark 点击下载中的全部暂停
  999. - (void)didClickAllSuspendInDownLoadingFun
  1000. {
  1001. _midTableView.downloadingHeadView.rightButton.selected = !_midTableView.downloadingHeadView.rightButton.selected;
  1002. if(_midTableView.downloadingHeadView.rightButton.selected){
  1003. [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  1004. }
  1005. else{
  1006. NSMutableArray *leftArr = _midTableView.downloadingArr;
  1007. [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:leftArr withAll:YES];
  1008. }
  1009. }
  1010. #pragma mark 点击下载成功的清空记录
  1011. - (void)didClickClearDownLoadRecordInDoneFun
  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_done_Tip_msg",nil)
  1017. imageStr:@""
  1018. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1019. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1020. didClickOk:^{
  1021. [weakSelf ClearAllRecordInDownloadDoneFun];
  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)ClearAllRecordInDownloadDoneFun
  1030. {
  1031. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
  1032. }
  1033. #pragma mark 点击下载失败的清空记录
  1034. - (void)didClickClearRecordInDownLoadFailFun
  1035. {
  1036. /*弹窗提示二次确认*/
  1037. KWeakSelf
  1038. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1039. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  1040. imageStr:@""
  1041. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1042. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1043. didClickOk:^{
  1044. [weakSelf ClearAllRecordInDownloadFailFun];
  1045. } didClickCancel:^{
  1046. }];
  1047. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1048. [self presentViewController:nextVC animated:YES completion:^{
  1049. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1050. }];
  1051. }
  1052. - (void)ClearAllRecordInDownloadFailFun
  1053. {
  1054. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
  1055. }
  1056. /**********************************接收相关******************************************/
  1057. - (void)setIsReceiveType:(NSInteger)isReceiveType
  1058. {
  1059. _isReceiveType = isReceiveType;
  1060. KWeakSelf
  1061. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1062. weakSelf.curReceiveView.isReceiveType = isReceiveType;
  1063. [weakSelf.curReceiveView getAllDataFun];
  1064. [weakSelf delayChangeUIFunWithIndex:4];
  1065. });
  1066. }
  1067. #pragma mark 删除云机文件数据
  1068. - (void)delFileListFunWithData:(NSArray*)delDataArr
  1069. {
  1070. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1071. if(delDataArr){
  1072. NSMutableArray*pathArr = [NSMutableArray new];
  1073. for (uploadFileDataModel *uploadFileDataMod in delDataArr) {
  1074. NSString *uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  1075. if(uploadDefaultPath && uploadDefaultPath.length > 0){
  1076. //判断最后一个是否是/
  1077. NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
  1078. if(![lastStr isEqualToString:@"/"]){
  1079. uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
  1080. }
  1081. NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,uploadFileDataMod.filename];
  1082. [pathArr addObject:savePath];
  1083. }
  1084. }
  1085. [paraDict setValue:pathArr forKey:@"path"];
  1086. }
  1087. //[self showNewIndicatorWithCanBack:YES canTouch:NO];
  1088. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1089. //KWeakSelf //@"delFile"
  1090. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1091. //[weakSelf removeNewIndicator];
  1092. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1093. if(model && model.status == 0){
  1094. //[[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1095. }
  1096. else{
  1097. }
  1098. } failure:^(NSError * _Nonnull error) {
  1099. //[weakSelf removeNewIndicator];
  1100. }];
  1101. }
  1102. @end