previewAudioOrDocumentViewController.m 32 KB

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