previewFileAndFolderSecondViewController.m 30 KB

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