NasPreviewAPPViewController.m 50 KB

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