previewAudioOrDocumentViewController.m 32 KB

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