previewAudioOrDocumentViewController.m 31 KB

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