previewAudioOrDocumentViewController.m 42 KB

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