previewFileAndFolderSecondViewController.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. //
  2. // previewFileAndFolderSecondViewController.m
  3. // Private-X
  4. //
  5. // Created by xd h on 2024/5/21.
  6. //
  7. #import "previewFileAndFolderSecondViewController.h"
  8. #import "couldPhoneFileListModel.h"
  9. #import "downloadManager.h"
  10. #import "uploadFileRecordViewController.h"
  11. #import "UIScrollView+EmptyDataSet.h"
  12. #import "diskListBgView.h"
  13. #import "diskListTableView.h"
  14. #import "downLoadPreViewCell.h"
  15. #import "editTypeHeadView.h"
  16. #import "editTypeBottomView.h"
  17. #import "editShareView.h"
  18. #import "previewToUploadFileView.h"
  19. #import "netWorkManager.h"
  20. #import "videoPlayByAVPlayerViewController.h"
  21. #import "audioPlayerViewController.h"
  22. #import "imageDetailsScrollViewController.h"
  23. #import "DocumentPickerManager.h"
  24. @interface previewFileAndFolderSecondViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  25. {
  26. UIButton* rightTransferListButton;//传输列表
  27. UIView* rightRedView;
  28. BOOL hadUploadTaskType;
  29. BOOL hadDownloadTaskType;
  30. }
  31. @property (nonatomic, strong) UITableView *tableView;
  32. @property(nonatomic,assign) BOOL isEditType;
  33. @property(nonatomic,strong) editTypeHeadView*curEditTypeHeadView;
  34. @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
  35. @property(nonatomic,strong) UIButton*uploadFileButton;
  36. @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
  37. @property (nonatomic, strong)NASFileAndFolderModel * curNASFileAudioMod;
  38. @end
  39. @implementation previewFileAndFolderSecondViewController
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. // Do any additional setup after loading the view.
  43. [self.toolBar setHidden:YES];
  44. [self.navigationBar setHidden:YES];
  45. [self.navBarBGView setHidden:NO];
  46. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  47. [self.view setBackgroundColor:[UIColor whiteColor]];
  48. [self drawAnyView];
  49. _didSelectListArr = [NSMutableArray new];
  50. }
  51. - (void)drawAnyView{
  52. [self initNavHeadUIFun];
  53. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  54. _curEditTypeHeadView.hidden = YES;
  55. [self.navBarBGView addSubview:_curEditTypeHeadView];
  56. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.mas_equalTo(0);
  58. make.right.mas_equalTo(0);
  59. make.bottom.mas_equalTo(0);
  60. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  61. }];
  62. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  63. KWeakSelf
  64. _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
  65. if(tag==1){
  66. [weakSelf userCancelEditTypeFun];
  67. }
  68. };
  69. _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
  70. [weakSelf didClickSelectAllButton:but];
  71. };
  72. _curEditTypeBottomView = [[editTypeBottomView alloc] init];
  73. _curEditTypeBottomView.hidden = YES;
  74. [self.view addSubview:_curEditTypeBottomView];
  75. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.mas_equalTo(0);
  77. make.right.mas_equalTo(0);
  78. make.bottom.mas_equalTo(0);
  79. make.height.mas_equalTo(60 + AdaptTabHeight);
  80. }];
  81. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  82. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  83. if(tag==1){
  84. [weakSelf gotoDownLoadFileFun];
  85. }
  86. else if(tag==2){
  87. [weakSelf gotoShareViewFun];
  88. }
  89. else if(tag==3){
  90. [weakSelf showDeleteAlearViewFun];
  91. }
  92. };
  93. [self.view addSubview:self.tableView];
  94. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.mas_equalTo(0);
  96. make.right.mas_equalTo(0);
  97. //make.bottom.mas_equalTo(-(safeArea));
  98. make.bottom.mas_equalTo(0);
  99. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  100. }];
  101. //大+号
  102. _uploadFileButton = [[UIButton alloc] init];
  103. [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
  104. [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
  105. [self.view addSubview:_uploadFileButton];
  106. [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.right.mas_equalTo(-15);
  108. make.width.mas_equalTo(52);
  109. make.height.mas_equalTo(52);
  110. make.bottom.mas_equalTo(-30 - AdaptTabHeight);
  111. }];
  112. }
  113. - (void)initNavHeadUIFun
  114. {
  115. rightTransferListButton = [[UIButton alloc] init];
  116. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  117. [rightTransferListButton addTarget:self action:@selector(didiClikRightButGotoTransferListFun:) forControlEvents:UIControlEventTouchUpInside];
  118. [self.navBarBGView addSubview:rightTransferListButton];
  119. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.width.mas_equalTo(40);
  121. make.height.mas_equalTo(40);
  122. make.right.mas_equalTo(-15);
  123. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  124. }];
  125. rightRedView = [[UIView alloc] init];
  126. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  127. [rightTransferListButton addSubview:rightRedView];
  128. rightRedView.layer.cornerRadius = 7;
  129. rightRedView.hidden = YES;
  130. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.width.mas_equalTo(14);
  132. make.height.mas_equalTo(14);
  133. make.right.mas_equalTo(0);
  134. make.top.mas_equalTo(6);
  135. }];
  136. }
  137. #pragma mark - 懒加载
  138. - (UITableView *)tableView{
  139. if (!_tableView) {
  140. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  141. _tableView.delegate = self;
  142. _tableView.dataSource = self;
  143. _tableView.showsVerticalScrollIndicator = NO;
  144. _tableView.showsHorizontalScrollIndicator = NO;
  145. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  146. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  147. [_tableView setSeparatorColor:[UIColor clearColor]];
  148. [_tableView setBackgroundColor:[UIColor clearColor]];
  149. [_tableView setTableFooterView:[UIView new]];
  150. [_tableView setBounces:YES];
  151. if (@available(iOS 15.0, *)) {
  152. _tableView.sectionHeaderTopPadding = 0;
  153. }
  154. //空数据引入第三方开源处理
  155. _tableView.emptyDataSetSource = self;
  156. _tableView.emptyDataSetDelegate = self;
  157. }
  158. return _tableView;
  159. }
  160. #pragma mark - 列表委托
  161. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  162. return 1;
  163. }
  164. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  165. if(!_curNASFileAudioMod){
  166. return 0;
  167. }
  168. return _curNASFileAudioMod.data.list.count;
  169. }
  170. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  171. __block NSInteger row = indexPath.row;
  172. static NSString *identifier = @"downLoadPreViewCell";
  173. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  174. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  175. if (!cell){
  176. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  177. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  178. [cell setBackgroundColor:[UIColor clearColor]];
  179. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  180. [cell.bgViewLayer removeFromSuperlayer];
  181. [cell.titleLabel2 setHidden:NO];
  182. [cell.rightImage setHidden:YES];
  183. [cell.lineView setHidden:YES];
  184. [cell.checkButton setHidden:NO];
  185. }
  186. if(row < _curNASFileAudioMod.data.list.count){
  187. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  188. cell.curNASFileAndFolderDataModel = dataModel;
  189. KWeakSelf
  190. cell.didClickSwitch = ^(BOOL SwitchOn) {
  191. //if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
  192. [weakSelf userCheckFilePreviewByRow:row];
  193. //}
  194. };
  195. }
  196. return cell;
  197. }
  198. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  199. return 70;
  200. }
  201. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  202. {
  203. NSInteger row = indexPath.row;
  204. if(row < _curNASFileAudioMod.data.list.count){
  205. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  206. if([dataModel.type isEqualToString:@"dir"])
  207. {
  208. previewFileAndFolderSecondViewController *vc = [previewFileAndFolderSecondViewController new];
  209. vc.curFolderDataModel = dataModel;
  210. vc.canShareType = _canShareType;
  211. [self.navigationController pushViewController:vc animated:YES];
  212. }
  213. else if([dataModel.type isEqualToString:@"video"]){
  214. videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
  215. vc.VideoDataMode = dataModel;
  216. [self.navigationController pushViewController:vc animated:YES];
  217. KWeakSelf
  218. // vc.didNeedToRegetDataFun = ^{
  219. // [weakSelf getFileListFun];
  220. // };
  221. }
  222. else if([dataModel.type isEqualToString:@"audio"]){
  223. // NSMutableArray *dataArr = [NSMutableArray new];
  224. // [dataArr addObject:dataModel];
  225. audioPlayerViewController *vc = [audioPlayerViewController new];
  226. vc.isfirstEnterType = YES;
  227. vc.outSideDataModel = (NASFileAudioDataModel *)dataModel;
  228. [self.navigationController pushViewController:vc animated:YES];
  229. KWeakSelf
  230. vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
  231. };
  232. // vc.didNeedToRegetDataFun = ^{
  233. // [weakSelf getFileListFun];
  234. // };
  235. }
  236. else if([dataModel.type containsString:@"jpg"]){
  237. NSMutableArray *jpgDataArr = [NSMutableArray new];
  238. NSInteger index = 0;
  239. [jpgDataArr addObject:dataModel];
  240. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  241. vc.index = index;
  242. vc.totalDataArr = jpgDataArr;
  243. [self.navigationController pushViewController:vc animated:YES];
  244. vc.canShareType = _canShareType;
  245. }
  246. }
  247. }
  248. #pragma mark 空数据
  249. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  250. NSString *imageName = @"common_no_data_pic";
  251. return [UIImage imageNamed:imageName];
  252. }
  253. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  254. NSString *text = NSLocalizedString(@"common_no_data_tip",nil);
  255. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  256. NSForegroundColorAttributeName: HW999999Color};
  257. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  258. }
  259. //调整图片位置
  260. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  261. return -150;
  262. }
  263. //ios端:
  264. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  265. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  266. //ios支持图片格式: (SVG 不支持)
  267. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  268. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  269. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  270. // NSString*name = [fileModel.name lowercaseString];
  271. // NSArray *nameArr = [name componentsSeparatedByString:@"."];
  272. // if(nameArr.count >0 && !_isAudioType){
  273. // BOOL canDownLoadType = NO;
  274. //
  275. // NSString *lastName = nameArr.lastObject;
  276. // if([lastName isEqualToString:@"mp4"]
  277. // ||[lastName isEqualToString:@"mov"]
  278. // ||[lastName isEqualToString:@"3gp"]
  279. // ||[lastName isEqualToString:@"m4v"]){
  280. // canDownLoadType = YES;
  281. // }
  282. //
  283. // if(!canDownLoadType){
  284. // if(canShow){
  285. // [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  286. // }
  287. //
  288. // return NO;
  289. // }
  290. // }
  291. //
  292. // if(nameArr.count >0 && _isAudioType){
  293. // BOOL canDownLoadType = NO;
  294. // //JPG 、PNG、GIF、TIFF、BMP
  295. // NSString *lastName = nameArr.lastObject;
  296. // if([lastName isEqualToString:@"jpg"]
  297. // ||[lastName isEqualToString:@"png"]
  298. // ||[lastName isEqualToString:@"gif"]
  299. // ||[lastName isEqualToString:@"tiff"]
  300. // ||[lastName isEqualToString:@"bmp"]
  301. // ||[lastName isEqualToString:@"heic"]
  302. // ||[lastName isEqualToString:@"jpeg"]
  303. // ||[lastName isEqualToString:@"heif"]){
  304. // canDownLoadType = YES;
  305. // }
  306. //
  307. // if(!canDownLoadType){
  308. // if(canShow){
  309. // [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  310. // }
  311. // return NO;
  312. // }
  313. // }
  314. return YES;
  315. }
  316. #pragma mark 用户长按图片进入编辑
  317. - (void)setViewEditTypeFun
  318. {
  319. _isEditType = YES;
  320. //[self.tableView reloadData];
  321. _curEditTypeHeadView.hidden = NO;
  322. _curEditTypeBottomView.hidden = NO;
  323. _uploadFileButton.hidden = YES;
  324. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  325. make.left.mas_equalTo(0);
  326. make.right.mas_equalTo(0);
  327. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  328. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  329. }];
  330. }
  331. #pragma mark 用户取消编辑编辑
  332. - (void)userCancelEditTypeFun
  333. {
  334. //数据还原
  335. for (NASFileAndFolderDataModel*model in _didSelectListArr) {
  336. model.isSelectType = NO;
  337. }
  338. [_didSelectListArr removeAllObjects];
  339. _isEditType = NO;
  340. [self.tableView reloadData];
  341. _curEditTypeHeadView.hidden = YES;
  342. _curEditTypeBottomView.hidden = YES;
  343. _uploadFileButton.hidden = NO;
  344. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  345. make.left.mas_equalTo(0);
  346. make.right.mas_equalTo(0);
  347. make.bottom.mas_equalTo(0);
  348. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  349. }];
  350. }
  351. - (void)userCheckFilePreviewByRow:(NSInteger)row
  352. {
  353. if(row < _curNASFileAudioMod.data.list.count){
  354. NASFileAudioDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  355. if(dataModel.isSelectType){
  356. [_didSelectListArr removeObject:dataModel];
  357. }
  358. else{
  359. [_didSelectListArr addObject:dataModel];
  360. }
  361. dataModel.isSelectType = !dataModel.isSelectType;
  362. [self setEditTypeTitleFun];
  363. }
  364. }
  365. - (void)didClickSelectAllButton:(UIButton*)button
  366. {
  367. //button.selected = !button.selected;
  368. [_didSelectListArr removeAllObjects];
  369. for (NASFileAudioDataModel* dataModel in _curNASFileAudioMod.data.list) {
  370. if(!button.selected){
  371. dataModel.isSelectType = button.selected;
  372. }
  373. else{
  374. if(![dataModel.type isEqualToString:@"dir"]){
  375. [_didSelectListArr addObject:dataModel];
  376. dataModel.isSelectType = button.selected;
  377. }
  378. }
  379. }
  380. [self.tableView reloadData];
  381. //[self.dataCollectionView reloadData];
  382. [self setEditTypeTitleFun];
  383. }
  384. #pragma mark 设置选中标题
  385. - (void)setEditTypeTitleFun
  386. {
  387. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  388. if(_didSelectListArr.count > 0){
  389. [self setViewEditTypeFun];
  390. }
  391. else{
  392. [self userCancelEditTypeFun];
  393. }
  394. }
  395. #pragma mark 用户点击分享
  396. - (void)gotoShareViewFun
  397. {
  398. //
  399. NSString * firstFileType = nil;
  400. BOOL isSameFileType = YES;
  401. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  402. if(!firstFileType){
  403. firstFileType = dataModel.type;
  404. }
  405. else if(![firstFileType isEqualToString:dataModel.type]){
  406. isSameFileType = NO;
  407. break;
  408. }
  409. }
  410. NSInteger MaxShareNuber = 50;
  411. // if(isSameFileType && [firstFileType containsString:@"video"]){
  412. // MaxShareNuber = 20;
  413. // }
  414. if (_didSelectListArr.count > MaxShareNuber) {
  415. [[iToast makeText:NSLocalizedString(@"share_max_count_tip1",nil)] show];
  416. return;
  417. }
  418. editShareView *editShareV = [[editShareView alloc] init];
  419. editShareV.didSelectListArr = _didSelectListArr;
  420. editShareV.shareFileType = @"6";
  421. [self.view addSubview:editShareV];
  422. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  423. make.left.mas_equalTo(0);
  424. make.right.mas_equalTo(0);
  425. make.bottom.mas_equalTo(0);
  426. make.top.mas_equalTo(0);
  427. }];
  428. }
  429. #pragma mark 用户点击上传文件
  430. - (void)userDidClickUploadViewFun
  431. {
  432. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  433. [self.view addSubview:previewToUploadFileV];
  434. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  435. make.left.mas_equalTo(0);
  436. make.right.mas_equalTo(0);
  437. make.bottom.mas_equalTo(0);
  438. make.top.mas_equalTo(0);
  439. }];
  440. KWeakSelf
  441. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  442. [weakSelf gotoUploadFileFunWith:tag];
  443. };
  444. }
  445. #pragma mark 设置标题
  446. - (void)viewWillAppear:(BOOL)animated
  447. {
  448. [super viewWillAppear:animated];
  449. }
  450. - (void)viewDidAppear:(BOOL)animated{
  451. [super viewDidAppear:animated];
  452. [self showDownloadTipFun];
  453. [self checkFileTransferTask];
  454. if(!_curNASFileAudioMod){
  455. self.titleLabel.text = _curFolderDataModel.name;
  456. [self getFileListFun];
  457. [self.curEditTypeBottomView setCanShaewFunBy:_canShareType];
  458. }
  459. }
  460. - (void)viewWillDisappear:(BOOL)animated{
  461. [super viewWillDisappear:animated];
  462. //[self removeNewIndicator];
  463. [self removeNewIndicatorHaveStr];
  464. }
  465. //- (void)setCurFolderDataModel:(NASFileAndFolderDataModel *)curFolderDataModel
  466. //{
  467. // _curFolderDataModel = curFolderDataModel;
  468. //}
  469. - (void)gotoDownloadloadFileRecordFun
  470. {
  471. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  472. [self.navigationController pushViewController:vc animated:YES];
  473. vc.isDownloadingType = YES;
  474. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  475. }
  476. - (void)showDownloadTipFun
  477. {
  478. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  479. if(didReadUploadTipType){
  480. return;
  481. }
  482. //KWeakSelf
  483. /*弹窗提示恢复出厂*/
  484. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
  485. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  486. imageStr:@""
  487. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  488. okTitle:@""
  489. isOkBtnHighlight:NO
  490. didClickOk:^{
  491. } didClickCancel:^{
  492. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  493. }];
  494. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  495. [self presentViewController:nextVC animated:YES completion:^{
  496. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  497. }];
  498. }
  499. - (void)checkFileTransferTask
  500. {//有个偶现的闪退在BGFMDB
  501. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  502. self->hadUploadTaskType = isSuccess;
  503. [self setRightButtonRedTypeFun];
  504. }];
  505. KWeakSelf
  506. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  507. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  508. self->hadDownloadTaskType = isSuccess;
  509. [weakSelf setRightButtonRedTypeFun];
  510. }];
  511. });
  512. }
  513. - (void)setRightButtonRedTypeFun
  514. {
  515. mainBlock(^{
  516. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  517. self->rightRedView.hidden = NO;
  518. }
  519. else{
  520. self->rightRedView.hidden = YES;
  521. }
  522. });
  523. }
  524. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  525. {
  526. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  527. [self.navigationController pushViewController:vc animated:YES];
  528. }
  529. #pragma mark 获取文件数据
  530. - (void)getFileListFun
  531. {
  532. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  533. if(_curFolderDataModel.path){
  534. [paraDict setValue:_curFolderDataModel.path forKey:@"path"];
  535. }
  536. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  537. KWeakSelf
  538. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileListByFolder" Parameters:paraDict success:^(id _Nonnull responseObject) {
  539. [weakSelf removeNewIndicatorHaveStr];
  540. weakSelf.curNASFileAudioMod = [[NASFileAndFolderModel alloc] initWithDictionary:responseObject error:nil];
  541. if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
  542. [weakSelf.tableView reloadData];
  543. }
  544. } failure:^(NSError * _Nonnull error) {
  545. [weakSelf removeNewIndicatorHaveStr];
  546. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  547. {
  548. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  549. }
  550. else{
  551. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  552. }
  553. }];
  554. }
  555. #pragma mark 调整文件上传
  556. - (void)gotoUploadFileFunWith:(NSInteger)tag
  557. {
  558. if(tag == 10 || tag == 11){
  559. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  560. if(tag ==10){
  561. vc.isPhotoType = YES;
  562. }
  563. else{
  564. vc.isPhotoType = NO;
  565. }
  566. [self.navigationController pushViewController:vc animated:YES];
  567. }
  568. else{
  569. KWeakSelf
  570. [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
  571. [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
  572. }];
  573. }
  574. }
  575. #pragma mark 文件下载
  576. - (void)gotoDownLoadFileFun
  577. {
  578. if(_didSelectListArr.count == 0){
  579. [[iToast makeText:@""] show];
  580. return;
  581. }
  582. NSMutableArray *arr = [NSMutableArray new];
  583. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  584. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  585. fileModel.fileType = dataModel.type;
  586. fileModel.path = dataModel.path;
  587. fileModel.name = dataModel.name;
  588. fileModel.length = dataModel.size;
  589. fileModel.time = dataModel.duration;
  590. [arr addObject:fileModel];
  591. }
  592. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  593. [self.navigationController pushViewController:vc animated:YES];
  594. vc.isDownloadingType = YES;
  595. [vc gotoDownloadFile:arr];
  596. }
  597. #pragma mark 删除图片
  598. - (void)showDeleteAlearViewFun
  599. {
  600. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  601. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  602. KWeakSelf
  603. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  604. msg:tipStr
  605. imageStr:@""
  606. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  607. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  608. didClickOk:^{
  609. [weakSelf delFileListFun];
  610. } didClickCancel:^{
  611. }];
  612. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  613. [self presentViewController:curAlretVC animated:YES completion:^{
  614. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  615. }];
  616. }
  617. #pragma mark 删除文件数据
  618. - (void)delFileListFun
  619. {
  620. //处理数据埋点
  621. NSString * firstFileType = nil;
  622. BOOL isSameFileType = YES;
  623. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  624. if(!firstFileType){
  625. firstFileType = dataModel.type;
  626. }
  627. else if(![firstFileType isEqualToString:dataModel.type]){
  628. isSameFileType = NO;
  629. break;
  630. }
  631. }
  632. if(!isSameFileType){
  633. //数据埋点
  634. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  635. }
  636. else if([firstFileType containsString:@"jpg"]){
  637. //数据埋点
  638. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_delete"];
  639. }
  640. else if([firstFileType isEqualToString:@"video"]){
  641. //数据埋点
  642. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  643. }
  644. else if([firstFileType isEqualToString:@"audio"]){
  645. //数据埋点
  646. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_delete"];
  647. }
  648. else{
  649. //数据埋点
  650. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  651. }
  652. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  653. NSMutableArray *pathArr = [NSMutableArray new];
  654. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  655. [pathArr addObject:dataModel.path];
  656. }
  657. [paraDict setValue:pathArr forKey:@"path"];
  658. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  659. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  660. KWeakSelf //@"delFile"
  661. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  662. [weakSelf removeNewIndicator];
  663. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  664. if(model && model.status == 0){
  665. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  666. [weakSelf didDeleteSucFun];
  667. }
  668. else{
  669. }
  670. } failure:^(NSError * _Nonnull error) {
  671. [weakSelf removeNewIndicator];
  672. }];
  673. }
  674. #pragma mark 删除成功
  675. - (void)didDeleteSucFun
  676. {
  677. //删除最近文件
  678. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  679. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  680. }
  681. [_didSelectListArr removeAllObjects];
  682. [self setEditTypeTitleFun];
  683. [self getFileListFun];
  684. }
  685. #pragma mark 文件上传跳转上传记录
  686. - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
  687. {
  688. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  689. [self.navigationController pushViewController:vc animated:YES];
  690. vc.isUploadingType = YES;
  691. [vc gotoUploadFileByFileApp:urls];
  692. }
  693. @end