NasPreviewAPPViewController.m 49 KB

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