previewFileAndFolderSecondViewController.m 27 KB

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