NasPreviewVideoViewController.m 32 KB

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