previewAudioOrDocumentViewController.m 44 KB

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