NasPreviewAPPViewController.m 50 KB

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