previewFileAndFolderSecondViewController.m 28 KB

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