NasPreviewAPPViewController.m 44 KB

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