NasPreviewVideoViewController.m 38 KB

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