previewFileAndFolderSecondViewController.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  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.didNeedToRegetDataFun = ^{
  230. [weakSelf getFileListFun];
  231. };
  232. }
  233. else if([dataModel.type containsString:@"jpg"]){
  234. NSMutableArray *jpgDataArr = [NSMutableArray new];
  235. NSInteger index = 0;
  236. [jpgDataArr addObject:dataModel];
  237. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  238. vc.index = index;
  239. vc.totalDataArr = jpgDataArr;
  240. [self.navigationController pushViewController:vc animated:YES];
  241. vc.canShareType = _canShareType;
  242. }
  243. }
  244. }
  245. #pragma mark 空数据
  246. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  247. NSString *imageName = @"common_no_data_pic";
  248. return [UIImage imageNamed:imageName];
  249. }
  250. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  251. NSString *text = NSLocalizedString(@"common_no_data_tip",nil);
  252. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  253. NSForegroundColorAttributeName: HW999999Color};
  254. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  255. }
  256. //调整图片位置
  257. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  258. return -150;
  259. }
  260. //ios端:
  261. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  262. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  263. //ios支持图片格式: (SVG 不支持)
  264. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  265. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  266. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  267. // NSString*name = [fileModel.name lowercaseString];
  268. // NSArray *nameArr = [name componentsSeparatedByString:@"."];
  269. // if(nameArr.count >0 && !_isAudioType){
  270. // BOOL canDownLoadType = NO;
  271. //
  272. // NSString *lastName = nameArr.lastObject;
  273. // if([lastName isEqualToString:@"mp4"]
  274. // ||[lastName isEqualToString:@"mov"]
  275. // ||[lastName isEqualToString:@"3gp"]
  276. // ||[lastName isEqualToString:@"m4v"]){
  277. // canDownLoadType = YES;
  278. // }
  279. //
  280. // if(!canDownLoadType){
  281. // if(canShow){
  282. // [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  283. // }
  284. //
  285. // return NO;
  286. // }
  287. // }
  288. //
  289. // if(nameArr.count >0 && _isAudioType){
  290. // BOOL canDownLoadType = NO;
  291. // //JPG 、PNG、GIF、TIFF、BMP
  292. // NSString *lastName = nameArr.lastObject;
  293. // if([lastName isEqualToString:@"jpg"]
  294. // ||[lastName isEqualToString:@"png"]
  295. // ||[lastName isEqualToString:@"gif"]
  296. // ||[lastName isEqualToString:@"tiff"]
  297. // ||[lastName isEqualToString:@"bmp"]
  298. // ||[lastName isEqualToString:@"heic"]
  299. // ||[lastName isEqualToString:@"jpeg"]
  300. // ||[lastName isEqualToString:@"heif"]){
  301. // canDownLoadType = YES;
  302. // }
  303. //
  304. // if(!canDownLoadType){
  305. // if(canShow){
  306. // [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  307. // }
  308. // return NO;
  309. // }
  310. // }
  311. return YES;
  312. }
  313. #pragma mark 用户长按图片进入编辑
  314. - (void)setViewEditTypeFun
  315. {
  316. _isEditType = YES;
  317. //[self.tableView reloadData];
  318. _curEditTypeHeadView.hidden = NO;
  319. _curEditTypeBottomView.hidden = NO;
  320. _uploadFileButton.hidden = YES;
  321. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  322. make.left.mas_equalTo(0);
  323. make.right.mas_equalTo(0);
  324. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  325. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  326. }];
  327. }
  328. #pragma mark 用户取消编辑编辑
  329. - (void)userCancelEditTypeFun
  330. {
  331. //数据还原
  332. for (NASFileAndFolderDataModel*model in _didSelectListArr) {
  333. model.isSelectType = NO;
  334. }
  335. [_didSelectListArr removeAllObjects];
  336. _isEditType = NO;
  337. [self.tableView reloadData];
  338. _curEditTypeHeadView.hidden = YES;
  339. _curEditTypeBottomView.hidden = YES;
  340. _uploadFileButton.hidden = NO;
  341. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  342. make.left.mas_equalTo(0);
  343. make.right.mas_equalTo(0);
  344. make.bottom.mas_equalTo(0);
  345. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  346. }];
  347. }
  348. - (void)userCheckFilePreviewByRow:(NSInteger)row
  349. {
  350. if(row < _curNASFileAudioMod.data.list.count){
  351. NASFileAudioDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  352. if(dataModel.isSelectType){
  353. [_didSelectListArr removeObject:dataModel];
  354. }
  355. else{
  356. [_didSelectListArr addObject:dataModel];
  357. }
  358. dataModel.isSelectType = !dataModel.isSelectType;
  359. [self setEditTypeTitleFun];
  360. }
  361. }
  362. - (void)didClickSelectAllButton:(UIButton*)button
  363. {
  364. //button.selected = !button.selected;
  365. [_didSelectListArr removeAllObjects];
  366. for (NASFileAudioDataModel* dataModel in _curNASFileAudioMod.data.list) {
  367. if(!button.selected){
  368. dataModel.isSelectType = button.selected;
  369. }
  370. else{
  371. if(![dataModel.type isEqualToString:@"dir"]){
  372. [_didSelectListArr addObject:dataModel];
  373. dataModel.isSelectType = button.selected;
  374. }
  375. }
  376. }
  377. [self.tableView reloadData];
  378. //[self.dataCollectionView reloadData];
  379. [self setEditTypeTitleFun];
  380. }
  381. #pragma mark 设置选中标题
  382. - (void)setEditTypeTitleFun
  383. {
  384. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  385. if(_didSelectListArr.count > 0){
  386. [self setViewEditTypeFun];
  387. }
  388. else{
  389. [self userCancelEditTypeFun];
  390. }
  391. }
  392. #pragma mark 用户点击分享
  393. - (void)gotoShareViewFun
  394. {
  395. //
  396. NSString * firstFileType = nil;
  397. BOOL isSameFileType = YES;
  398. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  399. if(!firstFileType){
  400. firstFileType = dataModel.type;
  401. }
  402. else if(![firstFileType isEqualToString:dataModel.type]){
  403. isSameFileType = NO;
  404. break;
  405. }
  406. }
  407. NSInteger MaxShareNuber = 5;
  408. if(isSameFileType && [firstFileType containsString:@"video"]){
  409. MaxShareNuber = 20;
  410. }
  411. if (_didSelectListArr.count > MaxShareNuber) {
  412. if(MaxShareNuber==20)
  413. {
  414. [[iToast makeText:NSLocalizedString(@"share_max_count_tip1",nil)] show];
  415. }
  416. else{
  417. [[iToast makeText:NSLocalizedString(@"share_max_count_tip2",nil)] show];
  418. }
  419. return;
  420. }
  421. editShareView *editShareV = [[editShareView alloc] init];
  422. editShareV.didSelectListArr = _didSelectListArr;
  423. editShareV.shareFileType = @"6";
  424. [self.view addSubview:editShareV];
  425. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  426. make.left.mas_equalTo(0);
  427. make.right.mas_equalTo(0);
  428. make.bottom.mas_equalTo(0);
  429. make.top.mas_equalTo(0);
  430. }];
  431. }
  432. #pragma mark 用户点击上传文件
  433. - (void)userDidClickUploadViewFun
  434. {
  435. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  436. [self.view addSubview:previewToUploadFileV];
  437. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  438. make.left.mas_equalTo(0);
  439. make.right.mas_equalTo(0);
  440. make.bottom.mas_equalTo(0);
  441. make.top.mas_equalTo(0);
  442. }];
  443. KWeakSelf
  444. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  445. [weakSelf gotoUploadFileFunWith:tag];
  446. };
  447. }
  448. #pragma mark 设置标题
  449. - (void)viewWillAppear:(BOOL)animated
  450. {
  451. [super viewWillAppear:animated];
  452. }
  453. - (void)viewDidAppear:(BOOL)animated{
  454. [super viewDidAppear:animated];
  455. [self showDownloadTipFun];
  456. [self checkFileTransferTask];
  457. if(!_curNASFileAudioMod){
  458. self.titleLabel.text = _curFolderDataModel.name;
  459. [self getFileListFun];
  460. [self.curEditTypeBottomView setCanShaewFunBy:_canShareType];
  461. }
  462. }
  463. - (void)viewWillDisappear:(BOOL)animated{
  464. [super viewWillDisappear:animated];
  465. //[self removeNewIndicator];
  466. [self removeNewIndicatorHaveStr];
  467. }
  468. //- (void)setCurFolderDataModel:(NASFileAndFolderDataModel *)curFolderDataModel
  469. //{
  470. // _curFolderDataModel = curFolderDataModel;
  471. //}
  472. - (void)gotoDownloadloadFileRecordFun
  473. {
  474. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  475. [self.navigationController pushViewController:vc animated:YES];
  476. vc.isDownloadingType = YES;
  477. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  478. }
  479. - (void)showDownloadTipFun
  480. {
  481. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  482. if(didReadUploadTipType){
  483. return;
  484. }
  485. //KWeakSelf
  486. /*弹窗提示恢复出厂*/
  487. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
  488. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  489. imageStr:@""
  490. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  491. okTitle:@""
  492. isOkBtnHighlight:NO
  493. didClickOk:^{
  494. } didClickCancel:^{
  495. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  496. }];
  497. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  498. [self presentViewController:nextVC animated:YES completion:^{
  499. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  500. }];
  501. }
  502. - (void)checkFileTransferTask
  503. {//有个偶现的闪退在BGFMDB
  504. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  505. self->hadUploadTaskType = isSuccess;
  506. [self setRightButtonRedTypeFun];
  507. }];
  508. KWeakSelf
  509. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  510. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  511. self->hadDownloadTaskType = isSuccess;
  512. [weakSelf setRightButtonRedTypeFun];
  513. }];
  514. });
  515. }
  516. - (void)setRightButtonRedTypeFun
  517. {
  518. mainBlock(^{
  519. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  520. self->rightRedView.hidden = NO;
  521. }
  522. else{
  523. self->rightRedView.hidden = YES;
  524. }
  525. });
  526. }
  527. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  528. {
  529. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  530. [self.navigationController pushViewController:vc animated:YES];
  531. }
  532. #pragma mark 获取文件数据
  533. - (void)getFileListFun
  534. {
  535. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  536. if(_curFolderDataModel.path){
  537. [paraDict setValue:_curFolderDataModel.path forKey:@"path"];
  538. }
  539. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  540. KWeakSelf
  541. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileListByFolder" Parameters:paraDict success:^(id _Nonnull responseObject) {
  542. [weakSelf removeNewIndicatorHaveStr];
  543. weakSelf.curNASFileAudioMod = [[NASFileAndFolderModel alloc] initWithDictionary:responseObject error:nil];
  544. if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
  545. [weakSelf.tableView reloadData];
  546. }
  547. } failure:^(NSError * _Nonnull error) {
  548. [weakSelf removeNewIndicatorHaveStr];
  549. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  550. {
  551. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  552. }
  553. else{
  554. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  555. }
  556. }];
  557. }
  558. #pragma mark 调整文件上传
  559. - (void)gotoUploadFileFunWith:(NSInteger)tag
  560. {
  561. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  562. if(tag ==10){
  563. vc.isPhotoType = YES;
  564. }
  565. else{
  566. vc.isPhotoType = NO;
  567. }
  568. [self.navigationController pushViewController:vc animated:YES];
  569. }
  570. #pragma mark 文件下载
  571. - (void)gotoDownLoadFileFun
  572. {
  573. if(_didSelectListArr.count == 0){
  574. [[iToast makeText:@""] show];
  575. return;
  576. }
  577. NSMutableArray *arr = [NSMutableArray new];
  578. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  579. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  580. fileModel.fileType = dataModel.type;
  581. fileModel.path = dataModel.path;
  582. fileModel.name = dataModel.name;
  583. fileModel.length = dataModel.size;
  584. fileModel.time = dataModel.duration;
  585. [arr addObject:fileModel];
  586. }
  587. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  588. [self.navigationController pushViewController:vc animated:YES];
  589. vc.isDownloadingType = YES;
  590. [vc gotoDownloadFile:arr];
  591. }
  592. #pragma mark 删除图片
  593. - (void)showDeleteAlearViewFun
  594. {
  595. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  596. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  597. KWeakSelf
  598. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  599. msg:tipStr
  600. imageStr:@""
  601. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  602. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  603. didClickOk:^{
  604. [weakSelf delFileListFun];
  605. } didClickCancel:^{
  606. }];
  607. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  608. [self presentViewController:curAlretVC animated:YES completion:^{
  609. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  610. }];
  611. }
  612. #pragma mark 删除文件数据
  613. - (void)delFileListFun
  614. {
  615. //处理数据埋点
  616. NSString * firstFileType = nil;
  617. BOOL isSameFileType = YES;
  618. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  619. if(!firstFileType){
  620. firstFileType = dataModel.type;
  621. }
  622. else if(![firstFileType isEqualToString:dataModel.type]){
  623. isSameFileType = NO;
  624. break;
  625. }
  626. }
  627. if(!isSameFileType){
  628. //数据埋点
  629. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  630. }
  631. else if([firstFileType containsString:@"jpg"]){
  632. //数据埋点
  633. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_delete"];
  634. }
  635. else if([firstFileType isEqualToString:@"video"]){
  636. //数据埋点
  637. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  638. }
  639. else if([firstFileType isEqualToString:@"audio"]){
  640. //数据埋点
  641. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_delete"];
  642. }
  643. else{
  644. //数据埋点
  645. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"File_delete"];
  646. }
  647. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  648. NSMutableArray *pathArr = [NSMutableArray new];
  649. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  650. [pathArr addObject:dataModel.path];
  651. }
  652. [paraDict setValue:pathArr forKey:@"path"];
  653. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  654. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  655. KWeakSelf //@"delFile"
  656. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  657. [weakSelf removeNewIndicator];
  658. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  659. if(model && model.status == 0){
  660. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  661. [weakSelf didDeleteSucFun];
  662. }
  663. else{
  664. }
  665. } failure:^(NSError * _Nonnull error) {
  666. [weakSelf removeNewIndicator];
  667. }];
  668. }
  669. #pragma mark 删除成功
  670. - (void)didDeleteSucFun
  671. {
  672. //删除最近文件
  673. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  674. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  675. }
  676. [_didSelectListArr removeAllObjects];
  677. [self setEditTypeTitleFun];
  678. [self getFileListFun];
  679. }
  680. @end