NasPreviewAPPViewController.m 49 KB

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