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(!weakSelf.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. //
  512. // if(!isUserUploadIngType
  513. // &&(!upLoadingArr ||upLoadingArr.count == 0 || !isUploadIngType)){//不是上传状态
  514. // _leftTableView.uploadingHeadView.rightButton.selected = YES;
  515. // }
  516. // else if(upLoadingArr.count == _leftTableView.uploadingArr.count){
  517. // _leftTableView.uploadingHeadView.rightButton.selected = NO;
  518. // }
  519. // else{
  520. // _leftTableView.uploadingHeadView.rightButton.selected = YES;
  521. // }
  522. // }
  523. }
  524. #pragma mark 处理下载中的 全部暂停等
  525. - (void)handleDownloadingRightButFun
  526. {
  527. if(_midTableView.downloadingArr.count == 0){
  528. //不处理
  529. }
  530. else{
  531. NSMutableArray *downloadingArr = [nasDownloadFileManager shareInstance].downLoadFileModelDataArr;
  532. BOOL isDownloadIngType = [nasDownloadManager shareManager].isDownLoadIngType;
  533. if(!downloadingArr ||downloadingArr.count == 0 || !isDownloadIngType){//不是下载状态
  534. _midTableView.downloadingHeadView.rightButton.selected = YES;
  535. }
  536. else if(downloadingArr.count == _midTableView.downloadingArr.count){
  537. _midTableView.downloadingHeadView.rightButton.selected = NO;
  538. }
  539. else{
  540. _midTableView.downloadingHeadView.rightButton.selected = YES;
  541. }
  542. }
  543. }
  544. - (void)uploadFileRefreshFun:(NSNotification*)not
  545. {
  546. uploadFileDataModel *uploadFileDataMod = [not object];
  547. //HLog(@"%@",uploadFileDataMod);
  548. uploadFileDataMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  549. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  550. //HLog(@"传输列表的上传任务:%@",uploadingArr);
  551. for (int i=0; i<uploadingArr.count; i++) {
  552. uploadFileDataModel*preModel = uploadingArr[i];
  553. if(preModel.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
  554. [_leftTableView.uploadingArr replaceObjectAtIndex:i withObject:uploadFileDataMod];
  555. break;
  556. }
  557. }
  558. if(uploadFileDataMod.curUploadStateType == uploadStateDone
  559. || uploadFileDataMod.curUploadStateType == uploadStateFail){
  560. [self RefreshUploadViewFun];
  561. }
  562. else{
  563. [_leftTableView RefreshAllDataFun];
  564. }
  565. }
  566. - (void)uploadFileSuspendAllFun:(NSNotification*)not
  567. {
  568. NSMutableArray *uploadingArr = _leftTableView.uploadingArr;
  569. for (int i=0; i<uploadingArr.count; i++) {
  570. uploadFileDataModel*preModel = uploadingArr[i];
  571. if(preModel.curUploadStateType == uploadStateUploading
  572. ||preModel.curUploadStateType == uploadStateWait){
  573. preModel.curUploadStateType = uploadStateSuspend;
  574. //break;
  575. }
  576. }
  577. }
  578. #pragma mark 那上传那边的数据来更新页面
  579. - (void)RefreshUploadViewFun
  580. {
  581. KWeakSelf
  582. [[nasUploadFileManager shareInstance] getDataInDatabaseFun:NO complete:^(NSMutableArray * _Nonnull Arr) {
  583. //[weakSelf setRecordBodyDataFunBy:Arr];
  584. if(!Arr ||Arr.count != 3){
  585. HLog(@"数据库出错\n\n\n");
  586. return;
  587. }
  588. mainBlock(^{
  589. weakSelf.leftTableView.outSideDataArr = Arr;
  590. //[weakSelf handleUploadingRightButFun];
  591. });
  592. }];
  593. }
  594. #pragma mark 按钮点击
  595. - (void)didClickButFun:(UIButton*)but
  596. {
  597. NSInteger tag = but.tag;
  598. if(tag == 1){
  599. self.isEditType = NO;
  600. //self.uploadFileRecordBodyV.isEditType = NO;
  601. if(_selectIndex == 1){
  602. self.leftTableView.isEditType = NO;
  603. }
  604. else if(_selectIndex == 2){
  605. self.midTableView.isEditType = NO;
  606. }
  607. else if(_selectIndex == 3){
  608. //self.rightTableView.isEditType = NO;
  609. }
  610. }
  611. else{
  612. //self.uploadFileRecordBodyV.isSelectAllType = YES;
  613. but.selected = !but.selected;
  614. BOOL curSelectAllType = but.selected;
  615. if(_selectIndex == 1){
  616. self.leftTableView.isSelectAllType = curSelectAllType;
  617. }
  618. else if(_selectIndex == 2){
  619. self.midTableView.isSelectAllType = curSelectAllType;
  620. }
  621. else if(_selectIndex == 3){
  622. //self.rightTableView.isSelectAllType = YES;
  623. }
  624. else if(_selectIndex == 4){
  625. self.curReceiveView.isSelectAllType = curSelectAllType;
  626. }
  627. }
  628. }
  629. -(void)setIsEditType:(BOOL)isEditType
  630. {
  631. _isEditType = isEditType;
  632. _leftButton.hidden = !isEditType;
  633. _rightButton.hidden = !isEditType;
  634. self.backBtn.hidden = isEditType;
  635. _uploadFileRecordEditBottomV.hidden = !isEditType;
  636. _uploadFileRecordheadV.userInteractionEnabled = !isEditType;
  637. _uploadFileRecordBgScorllV.scrollEnabled = !isEditType;
  638. //_leftHeadView.rightButton.userInteractionEnabled = !isEditType;
  639. _curReceiveView.isEditType = isEditType;
  640. if(_isEditType){
  641. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15 - (60 + safeArea + AdaptTabHeight);
  642. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  643. make.left.mas_equalTo(0);
  644. make.right.mas_equalTo(0);
  645. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  646. make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top);
  647. }];
  648. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  649. make.left.mas_equalTo(SCREEN_W*0.0);
  650. make.width.mas_equalTo(SCREEN_W);
  651. make.top.mas_equalTo(0);
  652. make.height.mas_equalTo(curHeight);
  653. }];
  654. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  655. make.left.mas_equalTo(SCREEN_W*1.0);
  656. make.width.mas_equalTo(SCREEN_W);
  657. make.top.mas_equalTo(0);
  658. make.height.mas_equalTo(curHeight);
  659. }];
  660. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  661. make.left.mas_equalTo(SCREEN_W*2.0);
  662. make.width.mas_equalTo(SCREEN_W);
  663. make.top.mas_equalTo(0);
  664. make.height.mas_equalTo(curHeight);
  665. }];
  666. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  667. make.left.mas_equalTo(SCREEN_W*3.0);
  668. make.width.mas_equalTo(SCREEN_W);
  669. make.top.mas_equalTo(0);
  670. make.height.mas_equalTo(curHeight);
  671. }];
  672. }
  673. else{
  674. CGFloat curHeight = SCREEN_H - CGRectGetMaxY(self.navBarBGView.frame) - 50 - 15;
  675. [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
  676. make.left.mas_equalTo(0);
  677. make.right.mas_equalTo(0);
  678. make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
  679. make.bottom.mas_equalTo(0);
  680. }];
  681. [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  682. make.left.mas_equalTo(SCREEN_W*0.0);
  683. make.width.mas_equalTo(SCREEN_W);
  684. make.top.mas_equalTo(0);
  685. make.height.mas_equalTo(curHeight);
  686. }];
  687. [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  688. make.left.mas_equalTo(SCREEN_W*1.0);
  689. make.width.mas_equalTo(SCREEN_W);
  690. make.top.mas_equalTo(0);
  691. make.height.mas_equalTo(curHeight);
  692. }];
  693. [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  694. make.left.mas_equalTo(SCREEN_W*2.0);
  695. make.width.mas_equalTo(SCREEN_W);
  696. make.top.mas_equalTo(0);
  697. make.height.mas_equalTo(curHeight);
  698. }];
  699. [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
  700. make.left.mas_equalTo(SCREEN_W*3.0);
  701. make.width.mas_equalTo(SCREEN_W);
  702. make.top.mas_equalTo(0);
  703. make.height.mas_equalTo(curHeight);
  704. }];
  705. }
  706. }
  707. #pragma mark 点击上传中的全部暂停
  708. - (void)didClickAllSuspendInLoadingFun
  709. {
  710. _leftTableView.uploadingHeadView.rightButton.selected = !_leftTableView.uploadingHeadView.rightButton.selected;
  711. if(_leftTableView.uploadingHeadView.rightButton.selected){
  712. //[[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  713. [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  714. [_leftTableView reloadDataFun];
  715. }
  716. else{
  717. NSMutableArray *leftArr = _leftTableView.uploadingArr;
  718. //[[uploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  719. [[nasUploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
  720. }
  721. }
  722. #pragma mark 点击上传成功的清空记录
  723. - (void)didClickClearRecordInDoneFun
  724. {
  725. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  726. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  727. //
  728. // KWeakSelf
  729. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  730. // initWithTitle:titleStr
  731. // msg:nil
  732. // imageStr:nil
  733. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  734. // okTitle:NSLocalizedString(@"other_confirm",nil)
  735. // otherTitle:tipStr
  736. // isOkBtnHighlight:YES
  737. // didClickOk:^(BOOL isDeleteAll) {
  738. // [weakSelf didClickClearAllRecordInUploadDoneFun:isDeleteAll];
  739. // } didClickCancel:^{
  740. //
  741. // }];
  742. //
  743. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  744. //
  745. // [self presentViewController:curAlretVC animated:YES completion:^{
  746. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  747. // }];
  748. /*弹窗提示二次确认*/
  749. KWeakSelf
  750. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  751. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  752. imageStr:@""
  753. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  754. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  755. didClickOk:^{
  756. [weakSelf ClearAllRecordInDoneFun];
  757. } didClickCancel:^{
  758. }];
  759. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  760. [self presentViewController:nextVC animated:YES completion:^{
  761. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  762. }];
  763. }
  764. #pragma mark 确认要删除上传完成的任务
  765. - (void)didClickClearAllRecordInUploadDoneFun:(BOOL)isDeleteAllType
  766. {
  767. if(isDeleteAllType){
  768. [self delFileListFunWithData:_leftTableView.uploadDoneArr];
  769. }
  770. [self ClearAllRecordInDoneFun];
  771. }
  772. - (void)ClearAllRecordInDoneFun
  773. {
  774. [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadDoneArr withDelCache:YES complete:^(BOOL isSuccess) {
  775. HLog(@"isSuccess:%d",isSuccess);
  776. if(isSuccess){
  777. [self->_leftTableView.uploadDoneArr removeAllObjects];
  778. [self->_leftTableView reloadDataFun];
  779. }
  780. }];
  781. }
  782. #pragma mark 点击上传失败的清空记录
  783. - (void)didClickClearRecordInFailFun
  784. {
  785. // NSString *titleStr = NSLocalizedString(@"delete_upload_task_title_msg",nil);
  786. // NSString *tipStr = NSLocalizedString(@"delete_with_cloud_file_msg",nil);
  787. //
  788. // KWeakSelf
  789. // ComontAlretDeleteTypeViewController *curAlretVC= [[ComontAlretDeleteTypeViewController alloc]
  790. // initWithTitle:titleStr
  791. // msg:nil
  792. // imageStr:nil
  793. // cancelTitle:NSLocalizedString(@"other_cancel",nil)
  794. // okTitle:NSLocalizedString(@"other_confirm",nil)
  795. // otherTitle:tipStr
  796. // isOkBtnHighlight:YES
  797. // didClickOk:^(BOOL isDeleteAll) {
  798. // [weakSelf didClickClearAllRecordInUploadFailFun:isDeleteAll];
  799. // } didClickCancel:^{
  800. //
  801. // }];
  802. //
  803. // curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  804. //
  805. // [self presentViewController:curAlretVC animated:YES completion:^{
  806. // curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  807. // }];
  808. /*弹窗提示二次确认*/
  809. KWeakSelf
  810. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  811. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  812. imageStr:@""
  813. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  814. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  815. didClickOk:^{
  816. [weakSelf ClearAllRecordInFailFun];
  817. } didClickCancel:^{
  818. }];
  819. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  820. [self presentViewController:nextVC animated:YES completion:^{
  821. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  822. }];
  823. }
  824. #pragma mark 确认要删除上传失败的任务
  825. - (void)didClickClearAllRecordInUploadFailFun:(BOOL)isDeleteAllType
  826. {
  827. if(isDeleteAllType){
  828. [self delFileListFunWithData:_leftTableView.uploadfailArr];
  829. }
  830. [self ClearAllRecordInFailFun];
  831. }
  832. - (void)ClearAllRecordInFailFun
  833. {
  834. [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:_leftTableView.uploadfailArr withDelCache:YES complete:^(BOOL isSuccess) {
  835. HLog(@"isSuccess:%d",isSuccess);
  836. if(isSuccess){
  837. [self->_leftTableView.uploadfailArr removeAllObjects];
  838. [self->_leftTableView reloadDataFun];
  839. }
  840. }];
  841. }
  842. -(void)backBtnPressed{
  843. //[super backBtnPressed];
  844. NSArray *vcArrs = self.navigationController.viewControllers;
  845. NSInteger count = vcArrs.count;
  846. UIViewController *vc = nil;
  847. if(count > 2){
  848. UIViewController *lastVC = vcArrs[count-2];
  849. if([lastVC isKindOfClass:[uploadImageOrVideoViewController class]]){
  850. vc = vcArrs[count-3];
  851. }
  852. }
  853. if(vc){
  854. [self.navigationController popToViewController:vc animated:YES];
  855. }
  856. else{
  857. [self.navigationController popViewControllerAnimated:YES];
  858. }
  859. }
  860. - (void)backupsFileRefreshFun:(NSNotification*)not
  861. {
  862. photosBackupsTaskModel *photosBackupsTaskMod = [not object];
  863. //HLog(@"%@",uploadFileDataMod);
  864. if(photosBackupsTaskMod.didBackupsOneFileType){
  865. photosBackupsTaskMod.curTimeInterval = 0;
  866. photosBackupsTaskMod.preTimeInterval = 0;
  867. }
  868. else{
  869. photosBackupsTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  870. }
  871. _rightTableView.photosBackupsIngTaskModel = photosBackupsTaskMod;
  872. }
  873. -(void)gotoDownloadFile:(NSMutableArray*)selectedItems
  874. {
  875. KWeakSelf
  876. [[nasDownloadFileManager shareInstance] addNasDownloadRecordFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  877. weakSelf.didGetDownloadDataType = YES;
  878. [weakSelf handleRemoveIndicator];
  879. if(!Arr ||Arr.count != 3){
  880. HLog(@"数据库出错\n\n\n");
  881. return;
  882. }
  883. //NSMutableArray *curLoadIngArr = Arr[0];
  884. mainBlock(^{
  885. weakSelf.midTableView.outSideDataArr = Arr;
  886. [weakSelf.midTableView reloadDataFun];
  887. //[weakSelf handleUploadingRightButFun];
  888. });
  889. }];
  890. // [[downloadManager shareInstance] handleCouldPhoneFileModelToDownloadFileDataFunBy:selectedItems complete:^(NSMutableArray * _Nonnull Arr) {
  891. //
  892. // weakSelf.didGetDownloadDataType = YES;
  893. // [weakSelf handleRemoveIndicator];
  894. //
  895. // if(!Arr ||Arr.count != 3){
  896. // HLog(@"数据库出错\n\n\n");
  897. // return;
  898. // }
  899. //
  900. // //NSMutableArray *curLoadIngArr = Arr[0];
  901. //
  902. // mainBlock(^{
  903. // weakSelf.midTableView.outSideDataArr = Arr;
  904. // [weakSelf.midTableView reloadDataFun];
  905. // //[weakSelf handleUploadingRightButFun];
  906. // });
  907. // }];
  908. //处理数据埋点
  909. NSString * firstFileType = nil;
  910. BOOL isSameFileType = YES;
  911. for (couldPhoneFileModel*model in selectedItems) {
  912. if(!firstFileType){
  913. firstFileType = model.fileType;
  914. }
  915. else if(![firstFileType isEqualToString:model.fileType]){
  916. isSameFileType = NO;
  917. break;
  918. }
  919. }
  920. if(!isSameFileType){
  921. //数据埋点
  922. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  923. }
  924. else if([firstFileType containsString:@"jpg"]){
  925. //数据埋点
  926. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_download"];
  927. }
  928. else if([firstFileType isEqualToString:@"video"]){
  929. //数据埋点
  930. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_download"];
  931. }
  932. else if([firstFileType isEqualToString:@"audio"]){
  933. //数据埋点
  934. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_download"];
  935. }
  936. else{
  937. //数据埋点
  938. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_download"];
  939. }
  940. }
  941. #pragma mark nas http下载完成
  942. - (void)downloadTaskFinishedNoti:(NSNotification *)notification
  943. {
  944. //customDownloadOperation *model = notification.object;
  945. //NSString *url = model.url;
  946. [self getDownloadDataInDatabaseFun:NO];
  947. }
  948. - (void)downloadFileRefreshFun:(NSNotification*)not
  949. {
  950. couldPhoneFileModel *downloadTaskMod = [not object];
  951. if(!downloadTaskMod){
  952. [_midTableView RefreshAllDataFun];
  953. return;
  954. }
  955. HLog(@"hhhhhhh1 %@ didDownloadBytes:%ld",downloadTaskMod.name,downloadTaskMod.didDownloadBytes);
  956. downloadTaskMod.curTimeInterval = [[NSDate date] timeIntervalSince1970];
  957. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  958. for (int i=0; i<downloadingArr.count; i++) {
  959. couldPhoneFileModel*preModel = downloadingArr[i];
  960. if(preModel.bg_id.integerValue == downloadTaskMod.bg_id.integerValue){
  961. [_midTableView.downloadingArr replaceObjectAtIndex:i withObject:downloadTaskMod];
  962. break;
  963. }
  964. }
  965. if(downloadTaskMod.curDownloadStateType == downloadStateDone
  966. ||downloadTaskMod.curDownloadStateType == downloadStateFail){
  967. [self getDownloadDataInDatabaseFun:NO];
  968. }
  969. else{
  970. [_midTableView RefreshAllDataFun];
  971. }
  972. }
  973. - (void)downloadFileSuspendAllFun:(NSNotification*)not
  974. {
  975. NSMutableArray *downloadingArr = _midTableView.downloadingArr;
  976. for (int i=0; i<downloadingArr.count; i++) {
  977. couldPhoneFileModel*preModel = downloadingArr[i];
  978. if(preModel.curDownloadStateType == downloadStateUploading
  979. ||preModel.curDownloadStateType == downloadStateWait){
  980. preModel.curDownloadStateType = downloadStateSuspend;
  981. //break;
  982. }
  983. }
  984. [_midTableView RefreshAllDataFun];
  985. }
  986. #pragma mark 1.3版本UI修改后 下载文件列表的头部点击事件
  987. - (void)didClikRightButInDownloadTableVieFunBy:(NSInteger)section
  988. {
  989. if(section == 0){
  990. [self didClickAllSuspendInDownLoadingFun];
  991. }
  992. else if(section == 1){//成功
  993. [self didClickClearDownLoadRecordInDoneFun];
  994. }
  995. else if(section == 2){//失败
  996. [self didClickClearRecordInDownLoadFailFun];
  997. }
  998. }
  999. #pragma mark 点击下载中的全部暂停
  1000. - (void)didClickAllSuspendInDownLoadingFun
  1001. {
  1002. _midTableView.downloadingHeadView.rightButton.selected = !_midTableView.downloadingHeadView.rightButton.selected;
  1003. if(_midTableView.downloadingHeadView.rightButton.selected){
  1004. [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  1005. }
  1006. else{
  1007. NSMutableArray *leftArr = _midTableView.downloadingArr;
  1008. [[nasDownloadFileManager shareInstance] reDownloadFileFunBy:leftArr withAll:YES];
  1009. }
  1010. }
  1011. #pragma mark 点击下载成功的清空记录
  1012. - (void)didClickClearDownLoadRecordInDoneFun
  1013. {
  1014. /*弹窗提示二次确认*/
  1015. KWeakSelf
  1016. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1017. msg:NSLocalizedString(@"File_upload_Record_clear_done_Tip_msg",nil)
  1018. imageStr:@""
  1019. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1020. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1021. didClickOk:^{
  1022. [weakSelf ClearAllRecordInDownloadDoneFun];
  1023. } didClickCancel:^{
  1024. }];
  1025. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1026. [self presentViewController:nextVC animated:YES completion:^{
  1027. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1028. }];
  1029. }
  1030. - (void)ClearAllRecordInDownloadDoneFun
  1031. {
  1032. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadDoneArr withDelCache:YES];
  1033. }
  1034. #pragma mark 点击下载失败的清空记录
  1035. - (void)didClickClearRecordInDownLoadFailFun
  1036. {
  1037. /*弹窗提示二次确认*/
  1038. KWeakSelf
  1039. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1040. msg:NSLocalizedString(@"File_upload_Record_clear_fail_Tip_msg",nil)
  1041. imageStr:@""
  1042. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1043. okTitle:NSLocalizedString(@"other_comment_ok",nil) isOkBtnHighlight:YES
  1044. didClickOk:^{
  1045. [weakSelf ClearAllRecordInDownloadFailFun];
  1046. } didClickCancel:^{
  1047. }];
  1048. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1049. [self presentViewController:nextVC animated:YES completion:^{
  1050. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1051. }];
  1052. }
  1053. - (void)ClearAllRecordInDownloadFailFun
  1054. {
  1055. [[nasDownloadFileManager shareInstance] deleteDownloadFileRecordBy:_midTableView.downloadfailArr withDelCache:YES];
  1056. }
  1057. /**********************************接收相关******************************************/
  1058. - (void)setIsReceiveType:(NSInteger)isReceiveType
  1059. {
  1060. _isReceiveType = isReceiveType;
  1061. KWeakSelf
  1062. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1063. weakSelf.curReceiveView.isReceiveType = isReceiveType;
  1064. [weakSelf.curReceiveView getAllDataFun];
  1065. [weakSelf delayChangeUIFunWithIndex:4];
  1066. });
  1067. }
  1068. #pragma mark 删除云机文件数据
  1069. - (void)delFileListFunWithData:(NSArray*)delDataArr
  1070. {
  1071. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1072. if(delDataArr){
  1073. NSMutableArray*pathArr = [NSMutableArray new];
  1074. for (uploadFileDataModel *uploadFileDataMod in delDataArr) {
  1075. NSString *uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)];
  1076. if(uploadDefaultPath && uploadDefaultPath.length > 0){
  1077. //判断最后一个是否是/
  1078. NSString *lastStr= [uploadDefaultPath substringFromIndex:uploadDefaultPath.length-1];
  1079. if(![lastStr isEqualToString:@"/"]){
  1080. uploadDefaultPath = [[NSString alloc] initWithFormat:@"%@/",uploadDefaultPath];
  1081. }
  1082. NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,uploadFileDataMod.filename];
  1083. [pathArr addObject:savePath];
  1084. }
  1085. }
  1086. [paraDict setValue:pathArr forKey:@"path"];
  1087. }
  1088. //[self showNewIndicatorWithCanBack:YES canTouch:NO];
  1089. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1090. //KWeakSelf //@"delFile"
  1091. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1092. //[weakSelf removeNewIndicator];
  1093. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1094. if(model && model.status == 0){
  1095. //[[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1096. }
  1097. else{
  1098. }
  1099. } failure:^(NSError * _Nonnull error) {
  1100. //[weakSelf removeNewIndicator];
  1101. }];
  1102. }
  1103. @end