previewFileAndFolderSecondViewController.m 29 KB

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