previewFileAndFolderViewController.m 41 KB

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