NasPreviewAPPViewController.m 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477
  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. [self queryTVSwitchFunFun];
  780. }
  781. }
  782. - (void)viewWillDisappear:(BOOL)animated{
  783. [super viewWillDisappear:animated];
  784. //[self removeNewIndicator];
  785. [self removeNewIndicatorHaveStr];
  786. }
  787. - (void)gotoDownloadloadFileRecordFun
  788. {
  789. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  790. [self.navigationController pushViewController:vc animated:YES];
  791. vc.isDownloadingType = YES;
  792. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  793. }
  794. - (void)showDownloadTipFun
  795. {
  796. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  797. if(didReadUploadTipType){
  798. return;
  799. }
  800. //KWeakSelf
  801. /*弹窗提示恢复出厂*/
  802. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
  803. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  804. imageStr:@""
  805. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  806. okTitle:@""
  807. isOkBtnHighlight:NO
  808. didClickOk:^{
  809. } didClickCancel:^{
  810. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  811. }];
  812. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  813. [self presentViewController:nextVC animated:YES completion:^{
  814. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  815. }];
  816. }
  817. - (void)checkFileTransferTask
  818. {//有个偶现的闪退在BGFMDB
  819. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  820. self->hadUploadTaskType = isSuccess;
  821. [self setRightButtonRedTypeFun];
  822. }];
  823. KWeakSelf
  824. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  825. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  826. self->hadDownloadTaskType = isSuccess;
  827. [weakSelf setRightButtonRedTypeFun];
  828. }];
  829. });
  830. }
  831. - (void)setRightButtonRedTypeFun
  832. {
  833. mainBlock(^{
  834. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  835. self->rightRedView.hidden = NO;
  836. }
  837. else{
  838. self->rightRedView.hidden = YES;
  839. }
  840. });
  841. }
  842. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  843. {
  844. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  845. [self.navigationController pushViewController:vc animated:YES];
  846. }
  847. #pragma mark 获取文件数据
  848. - (void)getFileListFun:(BOOL)isMoreDataType
  849. {
  850. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  851. // if(!isMoreDataType){
  852. // self.pageIndex = 0;
  853. // }
  854. // else{
  855. // self.pageIndex ++;
  856. // }
  857. //
  858. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  859. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  860. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  861. KWeakSelf
  862. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getInstalledApk" Parameters:paraDict success:^(id _Nonnull responseObject) {
  863. //[weakSelf.tableView.mj_footer endRefreshing];
  864. [weakSelf removeNewIndicatorHaveStr];
  865. getInstalledAppListModel *curModel = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
  866. if(curModel && curModel.status == 0){
  867. weakSelf.getInstalledAppListMod = curModel;
  868. [weakSelf RefreshAllUIFun];
  869. NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
  870. for (NSString *key in responseObject) {
  871. id object = IdDataDict[key];
  872. if(!object || [object isKindOfClass:[NSNull class]]){
  873. [IdDataDict removeObjectForKey:key];
  874. }
  875. }
  876. //数据缓存
  877. NSString *key = stringKeyAddSn(@"getInstalledApk");
  878. [HWDataManager setObjectWithKey:key value:IdDataDict];
  879. }
  880. } failure:^(NSError * _Nonnull error) {
  881. //[weakSelf.tableView.mj_footer endRefreshing];
  882. [weakSelf removeNewIndicatorHaveStr];
  883. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  884. {
  885. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  886. }
  887. else{
  888. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  889. }
  890. }];
  891. }
  892. #pragma mark 上拉或者点击更多数据
  893. - (void)getMoreNetWorkData
  894. {
  895. [self getFileListFun:YES];
  896. }
  897. #pragma mark 分页数据组装
  898. - (void)handelNetDataAfterFilterDataBy:(NASFileAudioModel*)NASFileAudioMod
  899. {
  900. // if(_getInstalledAppListMod && _getInstalledAppListMod.data ){
  901. // NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_getInstalledAppListMod.data];//旧数据
  902. // [handelDataArr addObjectsFromArray:NASFileAudioMod.data.list];//新数据
  903. //
  904. // _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)handelDataArr;
  905. // }
  906. // else{
  907. // _curNASFileAudioMod = NASFileAudioMod;
  908. // }
  909. //
  910. // if(_curNASFileAudioMod.data.list.count == 0 ){
  911. // self.tableView.mj_footer.hidden = YES;
  912. // }
  913. // else{
  914. // self.tableView.mj_footer.hidden = NO;
  915. // }
  916. }
  917. #pragma mark 获取未安装数据
  918. - (void)getUninstallAppListFun:(BOOL)isMoreDataType
  919. {
  920. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  921. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  922. if(diskNameArr && diskNameArr.count >= 2){
  923. NSString *name = diskNameArr.lastObject;
  924. if(name.length == 0)
  925. {
  926. name = diskNameArr[diskNameArr.count -2];
  927. }
  928. [paraDict setValue:name forKey:@"path"];
  929. }
  930. // if(_defaultDiskPath){
  931. // [paraDict setValue:_defaultDiskPath forKey:@"path"];
  932. // }
  933. // if(!isMoreDataType){
  934. // self.pageIndex = 0;
  935. // }
  936. // else{
  937. // self.pageIndex ++;
  938. // }
  939. //
  940. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  941. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  942. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  943. KWeakSelf
  944. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getUninstallApk" Parameters:paraDict success:^(id _Nonnull responseObject) {
  945. //[weakSelf.tableView.mj_footer endRefreshing];
  946. [weakSelf removeNewIndicatorHaveStr];
  947. weakSelf.getUninstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
  948. if(weakSelf.getUninstalledAppListMod && weakSelf.getUninstalledAppListMod.status == 0 ){
  949. [weakSelf RefreshAllUIFun];
  950. NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
  951. for (NSString *key in responseObject) {
  952. id object = IdDataDict[key];
  953. if(!object || [object isKindOfClass:[NSNull class]]){
  954. [IdDataDict removeObjectForKey:key];
  955. }
  956. }
  957. //数据缓存
  958. NSString *key = stringKeyAddSn(@"getUninstallApk");
  959. [HWDataManager setObjectWithKey:key value:IdDataDict];
  960. }
  961. } failure:^(NSError * _Nonnull error) {
  962. //[weakSelf.tableView.mj_footer endRefreshing];
  963. [weakSelf removeNewIndicatorHaveStr];
  964. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  965. {
  966. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  967. }
  968. else{
  969. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  970. }
  971. }];
  972. }
  973. #pragma mark 调整文件上传
  974. - (void)gotoUploadFileFunWith:(NSInteger)tag
  975. {
  976. if(tag == 10 || tag == 11){
  977. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  978. if(tag ==10){
  979. vc.isPhotoType = YES;
  980. }
  981. else{
  982. vc.isPhotoType = NO;
  983. }
  984. [self.navigationController pushViewController:vc animated:YES];
  985. }
  986. else{
  987. KWeakSelf
  988. [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
  989. [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
  990. }];
  991. }
  992. }
  993. #pragma mark 文件下载
  994. - (void)gotoDownLoadFileFun
  995. {
  996. if(_didSelectListArr.count == 0){
  997. [[iToast makeText:@""] show];
  998. return;
  999. }
  1000. NSMutableArray *arr = [NSMutableArray new];
  1001. for (getInstalledAppModel *dataModel in _didSelectListArr) {
  1002. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  1003. fileModel.fileType = @"apk";
  1004. fileModel.path = dataModel.path;
  1005. fileModel.name = dataModel.name;
  1006. if(dataModel.size > 0){
  1007. fileModel.length = dataModel.size;
  1008. }
  1009. else{
  1010. fileModel.length = dataModel.length;
  1011. }
  1012. //fileModel.time = dataModel.time;
  1013. [arr addObject:fileModel];
  1014. }
  1015. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1016. [self.navigationController pushViewController:vc animated:YES];
  1017. vc.isDownloadingType = YES;
  1018. [vc gotoDownloadFile:arr];
  1019. }
  1020. #pragma mark 删除图片
  1021. - (void)showDeleteAlearViewFun
  1022. {
  1023. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  1024. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  1025. KWeakSelf
  1026. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  1027. msg:tipStr
  1028. imageStr:nil
  1029. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1030. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  1031. didClickOk:^{
  1032. [weakSelf delFileListFun];
  1033. } didClickCancel:^{
  1034. }];
  1035. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1036. [self presentViewController:curAlretVC animated:YES completion:^{
  1037. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1038. }];
  1039. }
  1040. #pragma mark 删除文件数据
  1041. - (void)delFileListFun
  1042. {
  1043. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1044. NSMutableArray *pathArr = [NSMutableArray new];
  1045. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1046. [pathArr addObject:dataModel.path];
  1047. }
  1048. [paraDict setValue:pathArr forKey:@"path"];
  1049. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  1050. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1051. KWeakSelf //@"delFile"
  1052. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1053. [weakSelf removeNewIndicator];
  1054. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1055. if(model && model.status == 0){
  1056. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1057. [weakSelf didDeleteSucFun];
  1058. }
  1059. else{
  1060. }
  1061. } failure:^(NSError * _Nonnull error) {
  1062. [weakSelf removeNewIndicator];
  1063. }];
  1064. //数据埋点
  1065. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  1066. }
  1067. #pragma mark 删除成功
  1068. - (void)didDeleteSucFun
  1069. {
  1070. //删除最近文件
  1071. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1072. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  1073. }
  1074. //2.删除已经获取到的网络数据
  1075. [self deleteNetDataByDeleteSucFun];
  1076. [_didSelectListArr removeAllObjects];
  1077. [self setEditTypeTitleFun];
  1078. }
  1079. #pragma mark 删除成功后 对应删除原来获取的网络数据
  1080. - (void)deleteNetDataByDeleteSucFun
  1081. {
  1082. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1083. for (getInstalledAppModel *model in _getInstalledAppListMod.data) {
  1084. if (!model.isSelectType) {
  1085. [afterFilterArr addObject:model];
  1086. }
  1087. }
  1088. _getInstalledAppListMod.data = (NSArray<getInstalledAppModel>*)afterFilterArr;
  1089. [self.tableView reloadData];
  1090. }
  1091. #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
  1092. - (void)deleteNetDataByFilePath:(NSString*)filePath
  1093. {
  1094. if(!filePath || filePath.length == 0){
  1095. return;
  1096. }
  1097. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1098. for (getInstalledAppModel *model in _getInstalledAppListMod.data) {
  1099. if (![model.path isEqualToString:filePath]) {
  1100. [afterFilterArr addObject:model];
  1101. }
  1102. }
  1103. _getInstalledAppListMod.data = (NSArray<getInstalledAppModel>*)afterFilterArr;
  1104. [self.tableView reloadData];
  1105. }
  1106. #pragma mark 获取分享开关
  1107. -(void)queryShareSwitchFunFun
  1108. {
  1109. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1110. [paraDict setValue:@3 forKey:@"type"];
  1111. KWeakSelf
  1112. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  1113. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1114. if(queryShareMod){
  1115. self->canShareType = queryShareMod.data.configValue;
  1116. weakSelf.curEditTypeBottomView.isCanShareType = self->canShareType;
  1117. }
  1118. } failure:^(NSError * _Nonnull error) {
  1119. }];
  1120. }
  1121. #pragma mark 获取安装到TV开关
  1122. -(void)queryTVSwitchFunFun
  1123. {
  1124. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1125. [paraDict setValue:@"tv_switch_button" forKey:@"configKey"];
  1126. KWeakSelf
  1127. [[netWorkManager shareInstance] CommonGetWithCallBackCode:querySwitchButton Parameters:paraDict success:^(id _Nonnull responseObject){
  1128. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1129. if(queryShareMod){
  1130. BOOL canInstallToTVType = queryShareMod.data.configValue;
  1131. weakSelf.curEditTypeBottomView.isCanInstallToTVType = canInstallToTVType;
  1132. }
  1133. } failure:^(NSError * _Nonnull error) {
  1134. }];
  1135. }
  1136. #pragma mark 点击了已安装和未安装
  1137. - (void)didClickHeadTabButtonFun:(NSInteger)tag
  1138. {
  1139. if(tag == 1){
  1140. // _curInstalledAppListMod = _getInstalledAppListMod;
  1141. // self.curEditTypeBottomView.isCanDeleteType = NO;
  1142. isSecondTabType = NO;
  1143. }
  1144. else{
  1145. // _curInstalledAppListMod = _getUninstalledAppListMod;
  1146. // self.curEditTypeBottomView.isCanDeleteType = YES;
  1147. isSecondTabType = YES;
  1148. }
  1149. //[_tableView reloadData];
  1150. [self RefreshAllUIFun];
  1151. }
  1152. #pragma mark 安装APP到TV
  1153. - (void)ClickInstallAPPToTVFun
  1154. {
  1155. [self showInstallTVAlearViewFun];
  1156. }
  1157. #pragma mark 弹框二次确认安装到TV
  1158. - (void)showInstallTVAlearViewFun
  1159. {
  1160. NSInteger selectNum = _didSelectListArr.count;
  1161. NSString *titleStr = NSLocalizedString(@"alert_install_TV_title",nil);
  1162. NSString *tipStr1 = NSLocalizedString(@"alert_install_TV_msg_1",nil);
  1163. NSString *tipStr2 = NSLocalizedString(@"alert_install_TV_msg_2",nil);
  1164. NSString *tipStr3 = NSLocalizedString(@"alert_install_TV_msg_3",nil);
  1165. NSString * tipStr = [[NSString alloc] initWithFormat:@"%@%ld%@%ld%@",tipStr1,selectNum,tipStr2,selectNum*15,tipStr3];
  1166. KWeakSelf
  1167. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  1168. msg:tipStr
  1169. imageStr:@""
  1170. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1171. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  1172. didClickOk:^{
  1173. [[appToTVManager shareInstance] addAppToTVByList:weakSelf.didSelectListArr];
  1174. } didClickCancel:^{
  1175. }];
  1176. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1177. [self presentViewController:curAlretVC animated:YES completion:^{
  1178. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1179. }];
  1180. }
  1181. #pragma mark 点击了搜索
  1182. - (void)gotoSearchVCFun
  1183. {
  1184. NasSearchViewController *vc = [NasSearchViewController new];
  1185. vc.fileType = @"other";
  1186. [self.navigationController pushViewController:vc animated:YES];
  1187. }
  1188. #pragma mark 文件上传跳转上传记录
  1189. - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
  1190. {
  1191. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1192. [self.navigationController pushViewController:vc animated:YES];
  1193. vc.isUploadingType = YES;
  1194. [vc gotoUploadFileByFileApp:urls];
  1195. }
  1196. @end