NasPreviewAPPViewController.m 46 KB

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