uploadFileRecordViewController.m 49 KB

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