previewAudioOrDocumentViewController.m 43 KB

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