NasPreviewVideoViewController.m 36 KB

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