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