NasPreviewAPPViewController.m 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  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. self.curEditTypeBottomView.isCanDeleteType = YES;
  538. }
  539. else{
  540. _curInstalledAppListMod = _getInstalledAppListMod;
  541. self.curEditTypeBottomView.isCanDeleteType = NO;
  542. }
  543. if(isDefaultTabType //&& !isSecondTabType
  544. ){
  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. [_searchBarThridTypeV mas_remakeConstraints:^(MASConstraintMaker *make) {
  556. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  557. //make.top.equalTo(self.appInstallTypeV.mas_bottom).offset(10.f);
  558. make.height.mas_equalTo(32.0);
  559. make.left.mas_equalTo(20.0);
  560. //make.right.mas_equalTo(-48.0);
  561. make.right.mas_equalTo(-20.0);
  562. }];
  563. }
  564. [self.tableView reloadData];
  565. KWeakSelf
  566. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  567. make.left.mas_equalTo(0);
  568. make.right.mas_equalTo(0);
  569. if(weakSelf.isEditType){
  570. make.bottom.equalTo(weakSelf.curEditTypeBottomView.mas_top).offset(0.0);
  571. }
  572. else{
  573. make.bottom.mas_equalTo(0);
  574. }
  575. if(isDefaultTabType){
  576. if(self.searchBarThridTypeV.hidden){
  577. make.top.equalTo(self.appInstallTypeV.mas_bottom).offset(10.f);
  578. }
  579. else{
  580. make.top.equalTo(self.searchBarThridTypeV.mas_bottom).offset(10.f);
  581. }
  582. }
  583. else{
  584. if(self.searchBarThridTypeV.hidden){
  585. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  586. }
  587. else{
  588. make.top.equalTo(self.searchBarThridTypeV.mas_bottom).offset(10.f);
  589. }
  590. }
  591. }];
  592. }
  593. - (void)userCheckFilePreviewByRow:(NSInteger)row
  594. {
  595. if(row < _curInstalledAppListMod.data.count){
  596. NASFileAudioDataModel* dataModel = _curInstalledAppListMod.data[row];
  597. if(dataModel.isSelectType){
  598. [_didSelectListArr removeObject:dataModel];
  599. }
  600. else{
  601. [_didSelectListArr addObject:dataModel];
  602. }
  603. dataModel.isSelectType = !dataModel.isSelectType;
  604. [self setEditTypeTitleFun];
  605. }
  606. }
  607. - (void)didClickSelectAllButton:(UIButton*)button
  608. {
  609. //button.selected = !button.selected;
  610. [_didSelectListArr removeAllObjects];
  611. for (getInstalledAppModel* dataModel in _curInstalledAppListMod.data) {
  612. if(!button.selected){
  613. dataModel.isSelectType = button.selected;
  614. }
  615. else{
  616. [_didSelectListArr addObject:dataModel];
  617. dataModel.isSelectType = button.selected;
  618. }
  619. }
  620. [self.tableView reloadData];
  621. //[self.dataCollectionView reloadData];
  622. [self setEditTypeTitleFun];
  623. }
  624. #pragma mark 设置选中标题
  625. - (void)setEditTypeTitleFun
  626. {
  627. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  628. if(_didSelectListArr.count > 0){
  629. [self setViewEditTypeFun];
  630. }
  631. else{
  632. [self userCancelEditTypeFun];
  633. }
  634. }
  635. #pragma mark 用户点击分享
  636. - (void)gotoShareViewFun
  637. {
  638. if (_didSelectListArr.count > 5) {
  639. [[iToast makeText:NSLocalizedString(@"share_max_count_tip2",nil)] show];
  640. return;
  641. }
  642. NSMutableArray *changeModelArr = [NSMutableArray new];
  643. for (getInstalledAppModel* dataModel in _didSelectListArr) {
  644. NASFilePicDataArrModel *model = [NASFilePicDataArrModel new];
  645. model.type = @"apk";//dataModel.fileType;
  646. model.path = dataModel.path;
  647. model.name = dataModel.name;
  648. if(dataModel.size > 0){
  649. model.size = dataModel.size;
  650. }
  651. else{
  652. model.size = dataModel.length;
  653. }
  654. model.time = dataModel.time;
  655. [changeModelArr addObject:model];
  656. }
  657. editShareView *editShareV = [[editShareView alloc] init];
  658. editShareV.didSelectListArr = changeModelArr;
  659. editShareV.shareFileType = @"3";
  660. [self.view addSubview:editShareV];
  661. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  662. make.left.mas_equalTo(0);
  663. make.right.mas_equalTo(0);
  664. make.bottom.mas_equalTo(0);
  665. make.top.mas_equalTo(0);
  666. }];
  667. }
  668. #pragma mark 用户点击上传文件
  669. - (void)userDidClickUploadViewFun
  670. {
  671. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  672. [self.view addSubview:previewToUploadFileV];
  673. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  674. make.left.mas_equalTo(0);
  675. make.right.mas_equalTo(0);
  676. make.bottom.mas_equalTo(0);
  677. make.top.mas_equalTo(0);
  678. }];
  679. KWeakSelf
  680. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  681. [weakSelf gotoUploadFileFunWith:tag];
  682. };
  683. }
  684. #pragma mark 设置标题
  685. - (void)setTitleLabelText:(NSString*)title
  686. {
  687. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  688. if(diskNameArr && diskNameArr.count >= 2){
  689. NSString *name = diskNameArr.lastObject;
  690. if(name.length == 0)
  691. {
  692. name = diskNameArr[diskNameArr.count -2];
  693. }
  694. //name = [name stringByReplacingOccurrencesOfString:@"sdcard" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  695. name = [iTools changePathToShowPathBy:name];
  696. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  697. //判断是否为云机
  698. if([name isEqualToString:NSLocalizedString(@"disk_phone_default_tip",nil)]){
  699. isDefaultTabType = YES;
  700. _curInstalledAppListMod = _getInstalledAppListMod;
  701. }
  702. else{
  703. isDefaultTabType = NO;
  704. _curInstalledAppListMod = _getUninstalledAppListMod;
  705. }
  706. [self RefreshAllUIFun];
  707. }
  708. self.MytitleLabel.text = title;
  709. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  710. curWidth += 20;
  711. //HLog(@"title w:%f",curWidth);
  712. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  713. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  714. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  715. make.width.mas_equalTo(curWidth);
  716. make.height.mas_equalTo(30);
  717. }];
  718. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  719. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  720. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  721. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  722. make.width.mas_equalTo(15);
  723. make.height.mas_equalTo(15);
  724. }];
  725. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  726. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  727. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  728. make.width.mas_equalTo(curWidth+15);
  729. make.height.mas_equalTo(30);
  730. }];
  731. }
  732. #pragma mark 选择硬盘
  733. - (void)selectDiskAction:(UIButton*)but
  734. {
  735. if(self.diskListBgV.hidden){
  736. [self showDiskListVieFun];
  737. }
  738. else{
  739. [self hideDiskListVieFun];
  740. }
  741. }
  742. - (void)showDiskListVieFun
  743. {
  744. self.diskListBgV.hidden = NO;
  745. self.diskListTableV.hidden = NO;
  746. [UIView animateWithDuration:0.3 animations:^{
  747. CGRect rect = self.diskListTableV.frame;
  748. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  749. self.diskListTableV.frame = rect;
  750. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  751. }];
  752. }
  753. - (void)hideDiskListVieFun
  754. {
  755. self.diskListBgV.hidden = YES;
  756. [UIView animateWithDuration:0.3 animations:^{
  757. self.diskListTableV.hidden = YES;
  758. self.selectTip.transform = CGAffineTransformIdentity;
  759. }completion:^(BOOL finished) {
  760. CGRect rect = self.diskListTableV.frame;
  761. rect.origin.y = 0;
  762. self.diskListTableV.frame = rect;
  763. }];
  764. }
  765. #pragma mark 设置标题
  766. - (void)setTitleAfterGetdiskFun
  767. {
  768. [self setTitleLabelText:NSLocalizedString(@"nas_app_title",nil)];
  769. }
  770. - (void)viewWillAppear:(BOOL)animated
  771. {
  772. [super viewWillAppear:animated];
  773. }
  774. - (void)viewDidAppear:(BOOL)animated{
  775. [super viewDidAppear:animated];
  776. [self showDownloadTipFun];
  777. [self checkFileTransferTask];
  778. //if(!_getInstalledAppListMod)
  779. {
  780. [self getFileListFun:NO];
  781. [self getUninstallAppListFun:NO];
  782. [self queryShareSwitchFunFun];
  783. [self queryTVSwitchFunFun];
  784. }
  785. }
  786. - (void)viewWillDisappear:(BOOL)animated{
  787. [super viewWillDisappear:animated];
  788. //[self removeNewIndicator];
  789. [self removeNewIndicatorHaveStr];
  790. }
  791. - (void)gotoDownloadloadFileRecordFun
  792. {
  793. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  794. [self.navigationController pushViewController:vc animated:YES];
  795. vc.isDownloadingType = YES;
  796. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  797. }
  798. - (void)showDownloadTipFun
  799. {
  800. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  801. if(didReadUploadTipType){
  802. return;
  803. }
  804. //KWeakSelf
  805. /*弹窗提示恢复出厂*/
  806. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
  807. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  808. imageStr:@""
  809. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  810. okTitle:@""
  811. isOkBtnHighlight:NO
  812. didClickOk:^{
  813. } didClickCancel:^{
  814. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  815. }];
  816. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  817. [self presentViewController:nextVC animated:YES completion:^{
  818. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  819. }];
  820. }
  821. - (void)checkFileTransferTask
  822. {//有个偶现的闪退在BGFMDB
  823. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  824. self->hadUploadTaskType = isSuccess;
  825. [self setRightButtonRedTypeFun];
  826. }];
  827. KWeakSelf
  828. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  829. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  830. self->hadDownloadTaskType = isSuccess;
  831. [weakSelf setRightButtonRedTypeFun];
  832. }];
  833. });
  834. }
  835. - (void)setRightButtonRedTypeFun
  836. {
  837. mainBlock(^{
  838. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  839. self->rightRedView.hidden = NO;
  840. }
  841. else{
  842. self->rightRedView.hidden = YES;
  843. }
  844. });
  845. }
  846. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  847. {
  848. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  849. [self.navigationController pushViewController:vc animated:YES];
  850. }
  851. #pragma mark 获取文件数据
  852. - (void)getFileListFun:(BOOL)isMoreDataType
  853. {
  854. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  855. // if(!isMoreDataType){
  856. // self.pageIndex = 0;
  857. // }
  858. // else{
  859. // self.pageIndex ++;
  860. // }
  861. //
  862. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  863. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  864. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  865. KWeakSelf
  866. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getInstalledApk" Parameters:paraDict success:^(id _Nonnull responseObject) {
  867. //[weakSelf.tableView.mj_footer endRefreshing];
  868. [weakSelf removeNewIndicatorHaveStr];
  869. getInstalledAppListModel *curModel = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
  870. if(curModel && curModel.status == 0){
  871. weakSelf.getInstalledAppListMod = curModel;
  872. [weakSelf RefreshAllUIFun];
  873. NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
  874. for (NSString *key in responseObject) {
  875. id object = IdDataDict[key];
  876. if(!object || [object isKindOfClass:[NSNull class]]){
  877. [IdDataDict removeObjectForKey:key];
  878. }
  879. }
  880. //数据缓存
  881. NSString *key = stringKeyAddSn(@"getInstalledApk");
  882. [HWDataManager setObjectWithKey:key value:IdDataDict];
  883. }
  884. } failure:^(NSError * _Nonnull error) {
  885. //[weakSelf.tableView.mj_footer endRefreshing];
  886. [weakSelf removeNewIndicatorHaveStr];
  887. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  888. {
  889. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  890. }
  891. else{
  892. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  893. }
  894. }];
  895. }
  896. #pragma mark 上拉或者点击更多数据
  897. - (void)getMoreNetWorkData
  898. {
  899. [self getFileListFun:YES];
  900. }
  901. #pragma mark 分页数据组装
  902. - (void)handelNetDataAfterFilterDataBy:(NASFileAudioModel*)NASFileAudioMod
  903. {
  904. // if(_getInstalledAppListMod && _getInstalledAppListMod.data ){
  905. // NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_getInstalledAppListMod.data];//旧数据
  906. // [handelDataArr addObjectsFromArray:NASFileAudioMod.data.list];//新数据
  907. //
  908. // _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)handelDataArr;
  909. // }
  910. // else{
  911. // _curNASFileAudioMod = NASFileAudioMod;
  912. // }
  913. //
  914. // if(_curNASFileAudioMod.data.list.count == 0 ){
  915. // self.tableView.mj_footer.hidden = YES;
  916. // }
  917. // else{
  918. // self.tableView.mj_footer.hidden = NO;
  919. // }
  920. }
  921. #pragma mark 获取未安装数据
  922. - (void)getUninstallAppListFun:(BOOL)isMoreDataType
  923. {
  924. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  925. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  926. if(diskNameArr && diskNameArr.count >= 2){
  927. NSString *name = diskNameArr.lastObject;
  928. if(name.length == 0)
  929. {
  930. name = diskNameArr[diskNameArr.count -2];
  931. }
  932. [paraDict setValue:name forKey:@"path"];
  933. }
  934. // if(_defaultDiskPath){
  935. // [paraDict setValue:_defaultDiskPath forKey:@"path"];
  936. // }
  937. // if(!isMoreDataType){
  938. // self.pageIndex = 0;
  939. // }
  940. // else{
  941. // self.pageIndex ++;
  942. // }
  943. //
  944. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  945. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  946. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  947. KWeakSelf
  948. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getUninstallApk" Parameters:paraDict success:^(id _Nonnull responseObject) {
  949. //[weakSelf.tableView.mj_footer endRefreshing];
  950. [weakSelf removeNewIndicatorHaveStr];
  951. weakSelf.getUninstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
  952. if(weakSelf.getUninstalledAppListMod && weakSelf.getUninstalledAppListMod.status == 0 ){
  953. [weakSelf RefreshAllUIFun];
  954. NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
  955. for (NSString *key in responseObject) {
  956. id object = IdDataDict[key];
  957. if(!object || [object isKindOfClass:[NSNull class]]){
  958. [IdDataDict removeObjectForKey:key];
  959. }
  960. }
  961. //数据缓存
  962. NSString *key = stringKeyAddSn(@"getUninstallApk");
  963. [HWDataManager setObjectWithKey:key value:IdDataDict];
  964. }
  965. } failure:^(NSError * _Nonnull error) {
  966. //[weakSelf.tableView.mj_footer endRefreshing];
  967. [weakSelf removeNewIndicatorHaveStr];
  968. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  969. {
  970. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  971. }
  972. else{
  973. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  974. }
  975. }];
  976. }
  977. #pragma mark 调整文件上传
  978. - (void)gotoUploadFileFunWith:(NSInteger)tag
  979. {
  980. if(tag == 10 || tag == 11){
  981. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  982. if(tag ==10){
  983. vc.isPhotoType = YES;
  984. }
  985. else{
  986. vc.isPhotoType = NO;
  987. }
  988. [self.navigationController pushViewController:vc animated:YES];
  989. }
  990. else{
  991. KWeakSelf
  992. [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
  993. [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
  994. }];
  995. }
  996. }
  997. #pragma mark 文件下载
  998. - (void)gotoDownLoadFileFun
  999. {
  1000. if(_didSelectListArr.count == 0){
  1001. [[iToast makeText:@""] show];
  1002. return;
  1003. }
  1004. NSMutableArray *arr = [NSMutableArray new];
  1005. for (getInstalledAppModel *dataModel in _didSelectListArr) {
  1006. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  1007. fileModel.fileType = @"apk";
  1008. fileModel.path = dataModel.path;
  1009. fileModel.name = dataModel.name;
  1010. if(dataModel.size > 0){
  1011. fileModel.length = dataModel.size;
  1012. }
  1013. else{
  1014. fileModel.length = dataModel.length;
  1015. }
  1016. //fileModel.time = dataModel.time;
  1017. [arr addObject:fileModel];
  1018. }
  1019. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1020. [self.navigationController pushViewController:vc animated:YES];
  1021. vc.isDownloadingType = YES;
  1022. [vc gotoDownloadFile:arr];
  1023. }
  1024. #pragma mark 删除图片
  1025. - (void)showDeleteAlearViewFun
  1026. {
  1027. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  1028. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  1029. KWeakSelf
  1030. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  1031. msg:tipStr
  1032. imageStr:nil
  1033. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1034. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  1035. didClickOk:^{
  1036. [weakSelf delFileListFun];
  1037. } didClickCancel:^{
  1038. }];
  1039. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1040. [self presentViewController:curAlretVC animated:YES completion:^{
  1041. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1042. }];
  1043. }
  1044. #pragma mark 删除文件数据
  1045. - (void)delFileListFun
  1046. {
  1047. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1048. NSMutableArray *pathArr = [NSMutableArray new];
  1049. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1050. [pathArr addObject:dataModel.path];
  1051. }
  1052. [paraDict setValue:pathArr forKey:@"path"];
  1053. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  1054. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1055. KWeakSelf //@"delFile"
  1056. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1057. [weakSelf removeNewIndicator];
  1058. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1059. if(model && model.status == 0){
  1060. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1061. [weakSelf didDeleteSucFun];
  1062. }
  1063. else{
  1064. }
  1065. } failure:^(NSError * _Nonnull error) {
  1066. [weakSelf removeNewIndicator];
  1067. }];
  1068. //数据埋点
  1069. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  1070. }
  1071. #pragma mark 删除成功
  1072. - (void)didDeleteSucFun
  1073. {
  1074. //删除最近文件
  1075. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1076. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  1077. }
  1078. //2.删除已经获取到的网络数据
  1079. [self deleteNetDataByDeleteSucFun];
  1080. [_didSelectListArr removeAllObjects];
  1081. [self setEditTypeTitleFun];
  1082. }
  1083. #pragma mark 删除成功后 对应删除原来获取的网络数据
  1084. - (void)deleteNetDataByDeleteSucFun
  1085. {
  1086. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1087. for (getInstalledAppModel *model in _getInstalledAppListMod.data) {
  1088. if (!model.isSelectType) {
  1089. [afterFilterArr addObject:model];
  1090. }
  1091. }
  1092. _getInstalledAppListMod.data = (NSArray<getInstalledAppModel>*)afterFilterArr;
  1093. [self.tableView reloadData];
  1094. }
  1095. #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
  1096. - (void)deleteNetDataByFilePath:(NSString*)filePath
  1097. {
  1098. if(!filePath || filePath.length == 0){
  1099. return;
  1100. }
  1101. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1102. for (getInstalledAppModel *model in _getInstalledAppListMod.data) {
  1103. if (![model.path isEqualToString:filePath]) {
  1104. [afterFilterArr addObject:model];
  1105. }
  1106. }
  1107. _getInstalledAppListMod.data = (NSArray<getInstalledAppModel>*)afterFilterArr;
  1108. [self.tableView reloadData];
  1109. }
  1110. #pragma mark 获取分享开关
  1111. -(void)queryShareSwitchFunFun
  1112. {
  1113. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1114. [paraDict setValue:@3 forKey:@"type"];
  1115. KWeakSelf
  1116. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  1117. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1118. if(queryShareMod){
  1119. self->canShareType = queryShareMod.data.configValue;
  1120. weakSelf.curEditTypeBottomView.isCanShareType = self->canShareType;
  1121. }
  1122. } failure:^(NSError * _Nonnull error) {
  1123. }];
  1124. }
  1125. #pragma mark 获取安装到TV开关
  1126. -(void)queryTVSwitchFunFun
  1127. {
  1128. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1129. [paraDict setValue:@"tv_switch_button" forKey:@"configKey"];
  1130. KWeakSelf
  1131. [[netWorkManager shareInstance] CommonGetWithCallBackCode:querySwitchButton Parameters:paraDict success:^(id _Nonnull responseObject){
  1132. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1133. if(queryShareMod){
  1134. BOOL canInstallToTVType = queryShareMod.data.configValue;
  1135. weakSelf.curEditTypeBottomView.isCanInstallToTVType = canInstallToTVType;
  1136. }
  1137. } failure:^(NSError * _Nonnull error) {
  1138. }];
  1139. }
  1140. #pragma mark 点击了已安装和未安装
  1141. - (void)didClickHeadTabButtonFun:(NSInteger)tag
  1142. {
  1143. if(tag == 1){
  1144. // _curInstalledAppListMod = _getInstalledAppListMod;
  1145. // self.curEditTypeBottomView.isCanDeleteType = NO;
  1146. isSecondTabType = NO;
  1147. }
  1148. else{
  1149. // _curInstalledAppListMod = _getUninstalledAppListMod;
  1150. // self.curEditTypeBottomView.isCanDeleteType = YES;
  1151. isSecondTabType = YES;
  1152. }
  1153. //[_tableView reloadData];
  1154. [self RefreshAllUIFun];
  1155. }
  1156. #pragma mark 安装APP到TV
  1157. - (void)ClickInstallAPPToTVFun
  1158. {
  1159. [self showInstallTVAlearViewFun];
  1160. }
  1161. #pragma mark 弹框二次确认安装到TV
  1162. - (void)showInstallTVAlearViewFun
  1163. {
  1164. NSInteger selectNum = _didSelectListArr.count;
  1165. NSString *titleStr = NSLocalizedString(@"alert_install_TV_title",nil);
  1166. NSString *tipStr1 = NSLocalizedString(@"alert_install_TV_msg_1",nil);
  1167. NSString *tipStr2 = NSLocalizedString(@"alert_install_TV_msg_2",nil);
  1168. NSString *tipStr3 = NSLocalizedString(@"alert_install_TV_msg_3",nil);
  1169. NSString * tipStr = [[NSString alloc] initWithFormat:@"%@%ld%@%ld%@",tipStr1,selectNum,tipStr2,selectNum*15,tipStr3];
  1170. KWeakSelf
  1171. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  1172. msg:tipStr
  1173. imageStr:@""
  1174. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1175. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  1176. didClickOk:^{
  1177. [[appToTVManager shareInstance] addAppToTVByList:weakSelf.didSelectListArr];
  1178. } didClickCancel:^{
  1179. }];
  1180. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1181. [self presentViewController:curAlretVC animated:YES completion:^{
  1182. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1183. }];
  1184. }
  1185. #pragma mark 点击了搜索
  1186. - (void)gotoSearchVCFun
  1187. {
  1188. NasSearchAppViewController *vc = [NasSearchAppViewController new];
  1189. vc.isCanDeleteType = self.curEditTypeBottomView.isCanDeleteType;
  1190. vc.totalAPPListModel = _curInstalledAppListMod;
  1191. [self.navigationController pushViewController:vc animated:YES];
  1192. }
  1193. #pragma mark 文件上传跳转上传记录
  1194. - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
  1195. {
  1196. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1197. [self.navigationController pushViewController:vc animated:YES];
  1198. vc.isUploadingType = YES;
  1199. [vc gotoUploadFileByFileApp:urls];
  1200. }
  1201. @end