previewFileAndFolderSecondViewController.m 25 KB

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