NasPreviewAPPViewController.m 45 KB

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