NasPreviewAPPViewController.m 48 KB

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