previewAudioOrDocumentViewController.m 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  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(-65);
  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 queryShareSwitchFunFun];
  675. }
  676. }
  677. - (void)viewWillDisappear:(BOOL)animated{
  678. [super viewWillDisappear:animated];
  679. //[self removeNewIndicator];
  680. [self removeNewIndicatorHaveStr];
  681. }
  682. - (void)gotoDownloadloadFileRecordFun
  683. {
  684. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  685. [self.navigationController pushViewController:vc animated:YES];
  686. vc.isDownloadingType = YES;
  687. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  688. }
  689. - (void)showDownloadTipFun
  690. {
  691. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  692. if(didReadUploadTipType){
  693. return;
  694. }
  695. //KWeakSelf
  696. /*弹窗提示恢复出厂*/
  697. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  698. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  699. imageStr:nil
  700. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  701. okTitle:nil
  702. isOkBtnHighlight:NO
  703. didClickOk:^{
  704. } didClickCancel:^{
  705. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  706. }];
  707. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  708. [self presentViewController:nextVC animated:YES completion:^{
  709. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  710. }];
  711. }
  712. - (void)checkFileTransferTask
  713. {//有个偶现的闪退在BGFMDB
  714. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  715. self->hadUploadTaskType = isSuccess;
  716. [self setRightButtonRedTypeFun];
  717. }];
  718. KWeakSelf
  719. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  720. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  721. self->hadDownloadTaskType = isSuccess;
  722. [weakSelf setRightButtonRedTypeFun];
  723. }];
  724. });
  725. }
  726. - (void)setRightButtonRedTypeFun
  727. {
  728. mainBlock(^{
  729. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  730. self->rightRedView.hidden = NO;
  731. }
  732. else{
  733. self->rightRedView.hidden = YES;
  734. }
  735. });
  736. }
  737. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  738. {
  739. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  740. [self.navigationController pushViewController:vc animated:YES];
  741. }
  742. #pragma mark 获取文件数据
  743. - (void)getFileListFun:(BOOL)isMoreDataType
  744. {
  745. //无网 拿数据缓存
  746. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable
  747. ||[AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusUnknown
  748. )
  749. {
  750. //数据缓存
  751. NSString *fullPath = [[NSString alloc] initWithFormat:@"getFileList_audio_%@",self.defaultDiskPath];
  752. NSString *key = stringKeyAddSn(fullPath);
  753. NSDictionary *DataDict = [HWDataManager getObjectWithKey:key];
  754. if(DataDict){
  755. _curNASFileAudioMod = [[NASFileAudioModel alloc] initWithDictionary:DataDict error:nil];
  756. if(_curNASFileAudioMod && _curNASFileAudioMod.status == 0){
  757. for (NASFileAudioDataModel*model in _curNASFileAudioMod.data.list) {
  758. model.isOffLineType = YES;
  759. //判断是否有缓存
  760. BOOL isDidCacheType = [[audioPlayListManager shareManager] checkFileToDownloadDonewithPath:model.path];
  761. model.isDidCacheType = isDidCacheType;
  762. HLog(@"isDidCacheType: %d-%@",isDidCacheType,model.name)
  763. }
  764. [self.tableView reloadData];
  765. return;
  766. }
  767. }
  768. }
  769. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  770. if(_isAudioType){
  771. [paraDict setValue:@"audio" forKey:@"type"];
  772. }
  773. else{
  774. [paraDict setValue:@"file" forKey:@"type"];
  775. }
  776. // if(!isMoreDataType){
  777. // self.pageIndex = 0;
  778. // }
  779. // else{
  780. // self.pageIndex ++;
  781. // }
  782. //
  783. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  784. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  785. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  786. if(diskNameArr && diskNameArr.count >= 2){
  787. NSString *name = diskNameArr.lastObject;
  788. if(name.length == 0)
  789. {
  790. name = diskNameArr[diskNameArr.count -2];
  791. }
  792. [paraDict setValue:name forKey:@"path"];
  793. }
  794. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  795. KWeakSelf
  796. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileList" Parameters:paraDict success:^(id _Nonnull responseObject) {
  797. [weakSelf removeNewIndicatorHaveStr];
  798. //[weakSelf.tableView.mj_footer endRefreshing];
  799. NASFileAudioModel*NASFileAudioMod = [[NASFileAudioModel alloc] initWithDictionary:responseObject error:nil];
  800. // if(NASFileAudioMod.data.list.count < pageSizeNum){
  801. // [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  802. // }
  803. [weakSelf handelNetDataAfterFilterDataBy:NASFileAudioMod];
  804. if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
  805. [weakSelf.tableView reloadData];
  806. NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
  807. for (NSString *key in responseObject) {
  808. id object = IdDataDict[key];
  809. if(!object || [object isKindOfClass:[NSNull class]]){
  810. [IdDataDict removeObjectForKey:key];
  811. }
  812. }
  813. //数据缓存
  814. NSString *fullPath = [[NSString alloc] initWithFormat:@"getFileList_audio_%@",self.defaultDiskPath];
  815. NSString *key = stringKeyAddSn(fullPath);
  816. [HWDataManager setObjectWithKey:key value:IdDataDict];
  817. }
  818. } failure:^(NSError * _Nonnull error) {
  819. [weakSelf removeNewIndicatorHaveStr];
  820. //[weakSelf.tableView.mj_footer endRefreshing];
  821. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  822. {
  823. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  824. }
  825. else{
  826. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  827. }
  828. }];
  829. }
  830. #pragma mark 上拉或者点击更多数据
  831. - (void)getMoreNetWorkData
  832. {
  833. [self getFileListFun:YES];
  834. }
  835. #pragma mark 分页数据组装
  836. - (void)handelNetDataAfterFilterDataBy:(NASFileAudioModel*)NASFileAudioMod
  837. {
  838. if(_curNASFileAudioMod && _curNASFileAudioMod.data && _curNASFileAudioMod.data.list){
  839. NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_curNASFileAudioMod.data.list];//旧数据
  840. [handelDataArr addObjectsFromArray:NASFileAudioMod.data.list];//新数据
  841. _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)handelDataArr;
  842. }
  843. else{
  844. _curNASFileAudioMod = NASFileAudioMod;
  845. }
  846. // if(_curNASFileAudioMod.data.list.count == 0 ){
  847. // self.tableView.mj_footer.hidden = YES;
  848. // }
  849. // else{
  850. // self.tableView.mj_footer.hidden = NO;
  851. // }
  852. }
  853. #pragma mark 调整文件上传
  854. - (void)gotoUploadFileFunWith:(NSInteger)tag
  855. {
  856. if(tag == 10 || tag == 11){
  857. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  858. if(tag ==10){
  859. vc.isPhotoType = YES;
  860. }
  861. else{
  862. vc.isPhotoType = NO;
  863. }
  864. [self.navigationController pushViewController:vc animated:YES];
  865. }
  866. else{
  867. KWeakSelf
  868. [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
  869. [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
  870. }];
  871. }
  872. }
  873. #pragma mark 文件下载
  874. - (void)gotoDownLoadFileFun
  875. {
  876. if(_didSelectListArr.count == 0){
  877. [[iToast makeText:@""] show];
  878. return;
  879. }
  880. NSMutableArray *arr = [NSMutableArray new];
  881. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  882. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  883. fileModel.fileType = dataModel.type;
  884. fileModel.path = dataModel.path;
  885. fileModel.name = dataModel.name;
  886. fileModel.length = dataModel.size;
  887. fileModel.time = dataModel.duration;
  888. [arr addObject:fileModel];
  889. }
  890. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  891. [self.navigationController pushViewController:vc animated:YES];
  892. vc.isDownloadingType = YES;
  893. [vc gotoDownloadFile:arr];
  894. }
  895. #pragma mark 删除图片
  896. - (void)showDeleteAlearViewFun
  897. {
  898. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  899. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  900. KWeakSelf
  901. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  902. msg:tipStr
  903. imageStr:nil
  904. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  905. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  906. didClickOk:^{
  907. [weakSelf delFileListFun];
  908. } didClickCancel:^{
  909. }];
  910. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  911. [self presentViewController:curAlretVC animated:YES completion:^{
  912. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  913. }];
  914. }
  915. #pragma mark 删除文件数据
  916. - (void)delFileListFun
  917. {
  918. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  919. NSMutableArray *pathArr = [NSMutableArray new];
  920. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  921. [pathArr addObject:dataModel.path];
  922. }
  923. [paraDict setValue:pathArr forKey:@"path"];
  924. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  925. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  926. KWeakSelf //@"delFile"
  927. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  928. [weakSelf removeNewIndicator];
  929. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  930. if(model && model.status == 0){
  931. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  932. [weakSelf didDeleteSucFun];
  933. }
  934. else{
  935. }
  936. } failure:^(NSError * _Nonnull error) {
  937. [weakSelf removeNewIndicator];
  938. }];
  939. //数据埋点
  940. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_delete"];
  941. }
  942. #pragma mark 删除成功
  943. - (void)didDeleteSucFun
  944. {
  945. //删除最近文件
  946. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  947. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  948. }
  949. //2.删除已经获取到的网络数据
  950. [self deleteNetDataByDeleteSucFun];
  951. [_didSelectListArr removeAllObjects];
  952. [self setEditTypeTitleFun];
  953. }
  954. #pragma mark 删除成功后 对应删除原来获取的网络数据
  955. - (void)deleteNetDataByDeleteSucFun
  956. {
  957. NSMutableArray *afterFilterArr = [NSMutableArray new];
  958. for (NASFileAudioDataModel *model in _curNASFileAudioMod.data.list) {
  959. if (!model.isSelectType) {
  960. [afterFilterArr addObject:model];
  961. }
  962. }
  963. _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)afterFilterArr;
  964. [self.tableView reloadData];
  965. }
  966. #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
  967. - (void)deleteNetDataByFilePath:(NSString*)filePath
  968. {
  969. if(!filePath || filePath.length == 0){
  970. return;
  971. }
  972. NSMutableArray *afterFilterArr = [NSMutableArray new];
  973. for (NASFileAudioDataModel *model in _curNASFileAudioMod.data.list) {
  974. if (![model.path isEqualToString:filePath]) {
  975. [afterFilterArr addObject:model];
  976. }
  977. }
  978. _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)afterFilterArr;
  979. [self.tableView reloadData];
  980. }
  981. #pragma mark 获取分享开关
  982. -(void)queryShareSwitchFunFun
  983. {
  984. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  985. [paraDict setValue:@4 forKey:@"type"];
  986. KWeakSelf
  987. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  988. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  989. if(queryShareMod){
  990. self->canShareType = queryShareMod.data.configValue;
  991. [weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
  992. }
  993. } failure:^(NSError * _Nonnull error) {
  994. }];
  995. }
  996. #pragma mark 点击了搜索
  997. - (void)gotoSearchVCFun
  998. {
  999. NasSearchViewController *vc = [NasSearchViewController new];
  1000. vc.fileType = @"audio";
  1001. [self.navigationController pushViewController:vc animated:YES];
  1002. }
  1003. #pragma mark 文件上传跳转上传记录
  1004. - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
  1005. {
  1006. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1007. [self.navigationController pushViewController:vc animated:YES];
  1008. vc.isUploadingType = YES;
  1009. [vc gotoUploadFileByFileApp:urls];
  1010. }
  1011. #pragma - mark - 监听网络变化
  1012. - (void)networkStateChange:(NSNotification *)notification
  1013. {
  1014. [self checkNetWorkStateFun];
  1015. }
  1016. #pragma mark 判断缓存状态
  1017. - (void)checkNetWorkStateFun
  1018. {
  1019. //没有网络
  1020. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable
  1021. ||[AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusUnknown)
  1022. {
  1023. for (NASFileAudioDataModel*model in _curNASFileAudioMod.data.list) {
  1024. model.isOffLineType = YES;
  1025. //判断是否有缓存
  1026. BOOL isDidCacheType = [[audioPlayListManager shareManager] checkFileToDownloadDonewithPath:model.path];
  1027. model.isDidCacheType = isDidCacheType;
  1028. HLog(@"isDidCacheType: %d-%@",isDidCacheType,model.name)
  1029. }
  1030. }
  1031. else if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN
  1032. ||[AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi){
  1033. for (NASFileAudioDataModel*model in _curNASFileAudioMod.data.list) {
  1034. model.isOffLineType = NO;
  1035. }
  1036. }
  1037. [self.tableView reloadData];
  1038. }
  1039. #pragma mark 文件未缓存提示弹框
  1040. - (void)showPlayOffAndNotCacheLineFile
  1041. {
  1042. //KWeakSelf
  1043. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil)
  1044. msg:NSLocalizedString(@"audio_not_Cache_Tip",nil)
  1045. imageStr:@""
  1046. cancelTitle:NSLocalizedString(@"common_I_know",nil)
  1047. okTitle:@""
  1048. isOkBtnHighlight:NO
  1049. didClickOk:^{
  1050. } didClickCancel:^{
  1051. }];
  1052. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  1053. [self presentViewController:nextVC animated:YES completion:^{
  1054. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  1055. }];
  1056. }
  1057. @end