NasPreviewAPPViewController.m 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  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. NSString *keyUninstall = stringKeyAddSn(@"getUninstallApk");
  81. NSDictionary *DataDictUninstall = [HWDataManager getObjectWithKey:keyUninstall];
  82. if(DataDictUninstall){
  83. _getUninstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:DataDictUninstall error:nil];
  84. }
  85. [self drawAnyView];
  86. _didSelectListArr = [NSMutableArray new];
  87. //数据埋点
  88. //[[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Video"];
  89. }
  90. - (void)drawAnyView{
  91. [self initNavHeadUIFun];
  92. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  93. _curEditTypeHeadView.hidden = YES;
  94. [self.navBarBGView addSubview:_curEditTypeHeadView];
  95. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.left.mas_equalTo(0);
  97. make.right.mas_equalTo(0);
  98. make.bottom.mas_equalTo(0);
  99. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  100. }];
  101. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  102. KWeakSelf
  103. _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
  104. if(tag==1){
  105. [weakSelf userCancelEditTypeFun];
  106. }
  107. };
  108. _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
  109. [weakSelf didClickSelectAllButton:but];
  110. };
  111. _curEditTypeBottomView = [[editAPPBottomView alloc] init];
  112. _curEditTypeBottomView.hidden = YES;
  113. [self.view addSubview:_curEditTypeBottomView];
  114. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.left.mas_equalTo(0);
  116. make.right.mas_equalTo(0);
  117. make.bottom.mas_equalTo(0);
  118. make.height.mas_equalTo(60 + AdaptTabHeight);
  119. }];
  120. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  121. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  122. if(tag==1){
  123. [weakSelf gotoDownLoadFileFun];
  124. }
  125. else if(tag==2){
  126. [weakSelf gotoShareViewFun];
  127. }
  128. else if(tag==3){
  129. [weakSelf showDeleteAlearViewFun];
  130. }
  131. else if(tag==4){
  132. [weakSelf ClickInstallAPPToTVFun];
  133. }
  134. };
  135. //安装类型
  136. _appInstallTypeV = [[appInstallTypeView alloc] init];
  137. [self.view addSubview:_appInstallTypeV];
  138. [_appInstallTypeV mas_makeConstraints:^(MASConstraintMaker *make) {
  139. make.left.mas_equalTo(0);
  140. make.right.mas_equalTo(0);
  141. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  142. make.height.mas_equalTo(40);
  143. }];
  144. #pragma mark 点击已安装和未安装
  145. _appInstallTypeV.didClickbuttonFun = ^(NSInteger tag) {
  146. [weakSelf didClickHeadTabButtonFun:tag];
  147. };
  148. _searchBarThridTypeV = [[searchBarThridTypeView alloc] init];
  149. [self.view addSubview:_searchBarThridTypeV];
  150. [_searchBarThridTypeV mas_makeConstraints:^(MASConstraintMaker *make) {
  151. //make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  152. make.top.equalTo(self.appInstallTypeV.mas_bottom).offset(10.f);
  153. make.height.mas_equalTo(32.0);
  154. make.left.mas_equalTo(20.0);
  155. //make.right.mas_equalTo(-48.0);
  156. make.right.mas_equalTo(-20.0);
  157. }];
  158. #pragma mark 点击搜索
  159. _searchBarThridTypeV.didClickBgFun = ^{
  160. [weakSelf gotoSearchVCFun];
  161. };
  162. [self.view addSubview:self.tableView];
  163. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.left.mas_equalTo(0);
  165. make.right.mas_equalTo(0);
  166. //make.bottom.mas_equalTo(-(safeArea));
  167. make.bottom.mas_equalTo(0);
  168. //make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  169. //make.top.equalTo(self.appInstallTypeV.mas_bottom).offset(10.f);
  170. make.top.equalTo(self.searchBarThridTypeV.mas_bottom).offset(10.f);
  171. }];
  172. //大+号
  173. _uploadFileButton = [[UIButton alloc] init];
  174. [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
  175. [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
  176. [self.view addSubview:_uploadFileButton];
  177. [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
  178. make.right.mas_equalTo(-65);
  179. make.width.mas_equalTo(52);
  180. make.height.mas_equalTo(52);
  181. make.bottom.mas_equalTo(-30 - AdaptTabHeight);
  182. }];
  183. // 添加拖拽手势
  184. UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
  185. [_uploadFileButton addGestureRecognizer:panGesture];
  186. NSMutableArray *arr = [NSMutableArray new];
  187. NSArray *diskList = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  188. if(diskList && [diskList isKindOfClass:[NSArray class]]){
  189. for (cloudPhoneExtraFileModel *model in diskList) {
  190. model.isCheckType = NO;
  191. [arr addObject:model];
  192. }
  193. }
  194. if(arr.count >0){
  195. //上一次选中的磁盘
  196. NSString*preChekDiskStr = [HWDataManager getStringWithKey:Const_APP_pre_disk_check];
  197. //1.没有选择过 默认选择第一次(云机)
  198. if(!preChekDiskStr || preChekDiskStr.length == 0){
  199. cloudPhoneExtraFileModel *model = arr.firstObject;
  200. model.isCheckType = YES;
  201. _defaultDiskPath = model.extraPath;
  202. isDefaultTabType = YES;
  203. }
  204. else{//2.选择过 查询磁盘是否还存在
  205. BOOL didCheckDisk = NO;
  206. for (cloudPhoneExtraFileModel *model in arr) {
  207. HLog(@"磁盘路径比较 pre:%@---%@",preChekDiskStr,model.extraPath)
  208. if([model.extraPath isEqualToString:preChekDiskStr]){
  209. model.isCheckType = YES;
  210. _defaultDiskPath = model.extraPath;
  211. didCheckDisk = YES;
  212. break;
  213. }
  214. }
  215. isDefaultTabType = NO;
  216. //3.选择过 查询磁盘不存在
  217. if(!didCheckDisk){
  218. cloudPhoneExtraFileModel *model = arr.firstObject;
  219. model.isCheckType = YES;
  220. _defaultDiskPath = model.extraPath;
  221. isDefaultTabType = YES;
  222. }
  223. }
  224. }
  225. _diskListArr = arr;
  226. [self setTitleAfterGetdiskFun];
  227. }
  228. - (void)initNavHeadUIFun
  229. {
  230. //title
  231. UILabel *titleLabel = [[UILabel alloc] init];
  232. titleLabel.textAlignment = NSTextAlignmentCenter;
  233. titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  234. titleLabel.textColor = [UIColor blackColor];
  235. titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  236. [self.navBarBGView addSubview:titleLabel];
  237. self.MytitleLabel = titleLabel;
  238. //selectTipImageView
  239. UIImageView *selectTip = [[UIImageView alloc] init];
  240. selectTip.image = [UIImage imageNamed:@"upload_image_arrow"];
  241. selectTip.translatesAutoresizingMaskIntoConstraints = NO;
  242. [self.navBarBGView addSubview:selectTip];
  243. self.selectTip = selectTip;
  244. selectTip.hidden = YES;
  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 > 50) {
  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. //
  704. //title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  705. //判断是否为云机
  706. if([name isEqualToString:NSLocalizedString(@"disk_phone_default_tip",nil)]){
  707. isDefaultTabType = YES;
  708. _curInstalledAppListMod = _getInstalledAppListMod;
  709. }
  710. else{
  711. isDefaultTabType = NO;
  712. _curInstalledAppListMod = _getUninstalledAppListMod;
  713. }
  714. [self RefreshAllUIFun];
  715. }
  716. self.MytitleLabel.text = title;
  717. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  718. curWidth += 20;
  719. //HLog(@"title w:%f",curWidth);
  720. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  721. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  722. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  723. make.width.mas_equalTo(curWidth);
  724. make.height.mas_equalTo(30);
  725. }];
  726. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  727. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  728. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  729. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  730. make.width.mas_equalTo(15);
  731. make.height.mas_equalTo(15);
  732. }];
  733. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  734. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  735. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  736. make.width.mas_equalTo(curWidth+15);
  737. make.height.mas_equalTo(30);
  738. }];
  739. }
  740. #pragma mark 选择硬盘
  741. - (void)selectDiskAction:(UIButton*)but
  742. {
  743. if(self.diskListBgV.hidden){
  744. [self showDiskListVieFun];
  745. }
  746. else{
  747. [self hideDiskListVieFun];
  748. }
  749. }
  750. - (void)showDiskListVieFun
  751. {
  752. self.diskListBgV.hidden = NO;
  753. self.diskListTableV.hidden = NO;
  754. [UIView animateWithDuration:0.3 animations:^{
  755. CGRect rect = self.diskListTableV.frame;
  756. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  757. self.diskListTableV.frame = rect;
  758. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  759. }];
  760. }
  761. - (void)hideDiskListVieFun
  762. {
  763. self.diskListBgV.hidden = YES;
  764. [UIView animateWithDuration:0.3 animations:^{
  765. self.diskListTableV.hidden = YES;
  766. self.selectTip.transform = CGAffineTransformIdentity;
  767. }completion:^(BOOL finished) {
  768. CGRect rect = self.diskListTableV.frame;
  769. rect.origin.y = 0;
  770. self.diskListTableV.frame = rect;
  771. }];
  772. }
  773. #pragma mark 设置标题
  774. - (void)setTitleAfterGetdiskFun
  775. {
  776. [self setTitleLabelText:NSLocalizedString(@"nas_app_title",nil)];
  777. }
  778. - (void)viewWillAppear:(BOOL)animated
  779. {
  780. [super viewWillAppear:animated];
  781. }
  782. - (void)viewDidAppear:(BOOL)animated{
  783. [super viewDidAppear:animated];
  784. [self showDownloadTipFun];
  785. [self checkFileTransferTask];
  786. //if(!_getInstalledAppListMod)
  787. {
  788. [self getFileListFun:NO];
  789. [self getUninstallAppListFun:NO];
  790. [self queryShareSwitchFunFun];
  791. [self queryTVSwitchFunFun];
  792. }
  793. }
  794. - (void)viewWillDisappear:(BOOL)animated{
  795. [super viewWillDisappear:animated];
  796. //[self removeNewIndicator];
  797. [self removeNewIndicatorHaveStr];
  798. }
  799. - (void)gotoDownloadloadFileRecordFun
  800. {
  801. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  802. [self.navigationController pushViewController:vc animated:YES];
  803. vc.isDownloadingType = YES;
  804. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  805. }
  806. - (void)showDownloadTipFun
  807. {
  808. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  809. if(didReadUploadTipType){
  810. return;
  811. }
  812. //KWeakSelf
  813. /*弹窗提示恢复出厂*/
  814. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:@""
  815. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  816. imageStr:@""
  817. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  818. okTitle:@""
  819. isOkBtnHighlight:NO
  820. didClickOk:^{
  821. } didClickCancel:^{
  822. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  823. }];
  824. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  825. [self presentViewController:nextVC animated:YES completion:^{
  826. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  827. }];
  828. }
  829. - (void)checkFileTransferTask
  830. {//有个偶现的闪退在BGFMDB
  831. [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  832. self->hadUploadTaskType = isSuccess;
  833. [self setRightButtonRedTypeFun];
  834. }];
  835. KWeakSelf
  836. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  837. [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  838. self->hadDownloadTaskType = isSuccess;
  839. [weakSelf setRightButtonRedTypeFun];
  840. }];
  841. });
  842. }
  843. - (void)setRightButtonRedTypeFun
  844. {
  845. mainBlock(^{
  846. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  847. self->rightRedView.hidden = NO;
  848. }
  849. else{
  850. self->rightRedView.hidden = YES;
  851. }
  852. });
  853. }
  854. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  855. {
  856. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  857. [self.navigationController pushViewController:vc animated:YES];
  858. }
  859. #pragma mark 获取文件数据
  860. - (void)getFileListFun:(BOOL)isMoreDataType
  861. {
  862. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  863. // if(!isMoreDataType){
  864. // self.pageIndex = 0;
  865. // }
  866. // else{
  867. // self.pageIndex ++;
  868. // }
  869. //
  870. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  871. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  872. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  873. KWeakSelf
  874. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getInstalledApkNew" Parameters:paraDict success:^(id _Nonnull responseObject) {
  875. //[weakSelf.tableView.mj_footer endRefreshing];
  876. [weakSelf removeNewIndicatorHaveStr];
  877. getInstalledAppListModel *curModel = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
  878. if(curModel && curModel.status == 0){
  879. weakSelf.getInstalledAppListMod = curModel;
  880. [weakSelf RefreshAllUIFun];
  881. NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
  882. for (NSString *key in responseObject) {
  883. id object = IdDataDict[key];
  884. if(!object || [object isKindOfClass:[NSNull class]]){
  885. [IdDataDict removeObjectForKey:key];
  886. }
  887. }
  888. //数据缓存
  889. NSString *key = stringKeyAddSn(@"getInstalledApk");
  890. [HWDataManager setObjectWithKey:key value:IdDataDict];
  891. }
  892. } failure:^(NSError * _Nonnull error) {
  893. //[weakSelf.tableView.mj_footer endRefreshing];
  894. [weakSelf removeNewIndicatorHaveStr];
  895. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  896. {
  897. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  898. }
  899. else{
  900. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  901. }
  902. }];
  903. }
  904. #pragma mark 上拉或者点击更多数据
  905. - (void)getMoreNetWorkData
  906. {
  907. [self getFileListFun:YES];
  908. }
  909. #pragma mark 分页数据组装
  910. - (void)handelNetDataAfterFilterDataBy:(NASFileAudioModel*)NASFileAudioMod
  911. {
  912. // if(_getInstalledAppListMod && _getInstalledAppListMod.data ){
  913. // NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_getInstalledAppListMod.data];//旧数据
  914. // [handelDataArr addObjectsFromArray:NASFileAudioMod.data.list];//新数据
  915. //
  916. // _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)handelDataArr;
  917. // }
  918. // else{
  919. // _curNASFileAudioMod = NASFileAudioMod;
  920. // }
  921. //
  922. // if(_curNASFileAudioMod.data.list.count == 0 ){
  923. // self.tableView.mj_footer.hidden = YES;
  924. // }
  925. // else{
  926. // self.tableView.mj_footer.hidden = NO;
  927. // }
  928. }
  929. #pragma mark 获取未安装数据
  930. - (void)getUninstallAppListFun:(BOOL)isMoreDataType
  931. {
  932. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  933. // NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  934. // if(diskNameArr && diskNameArr.count >= 2){
  935. //
  936. // NSString *name = diskNameArr.lastObject;
  937. // if(name.length == 0)
  938. // {
  939. // name = diskNameArr[diskNameArr.count -2];
  940. // }
  941. //
  942. // [paraDict setValue:name forKey:@"path"];
  943. // }
  944. // if(_defaultDiskPath){
  945. // [paraDict setValue:_defaultDiskPath forKey:@"path"];
  946. // }
  947. // if(!isMoreDataType){
  948. // self.pageIndex = 0;
  949. // }
  950. // else{
  951. // self.pageIndex ++;
  952. // }
  953. //
  954. // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
  955. // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
  956. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  957. KWeakSelf
  958. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getUninstallApk" Parameters:paraDict success:^(id _Nonnull responseObject) {
  959. //[weakSelf.tableView.mj_footer endRefreshing];
  960. [weakSelf removeNewIndicatorHaveStr];
  961. weakSelf.getUninstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
  962. if(weakSelf.getUninstalledAppListMod && weakSelf.getUninstalledAppListMod.status == 0 ){
  963. [weakSelf RefreshAllUIFun];
  964. NSMutableDictionary *IdDataDict = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
  965. for (NSString *key in responseObject) {
  966. id object = IdDataDict[key];
  967. if(!object || [object isKindOfClass:[NSNull class]]){
  968. [IdDataDict removeObjectForKey:key];
  969. }
  970. }
  971. //数据缓存
  972. NSString *key = stringKeyAddSn(@"getUninstallApk");
  973. [HWDataManager setObjectWithKey:key value:IdDataDict];
  974. }
  975. } failure:^(NSError * _Nonnull error) {
  976. //[weakSelf.tableView.mj_footer endRefreshing];
  977. [weakSelf removeNewIndicatorHaveStr];
  978. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  979. {
  980. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  981. }
  982. else{
  983. [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
  984. }
  985. }];
  986. }
  987. #pragma mark 调整文件上传
  988. - (void)gotoUploadFileFunWith:(NSInteger)tag
  989. {
  990. if(tag == 10 || tag == 11){
  991. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  992. if(tag ==10){
  993. vc.isPhotoType = YES;
  994. }
  995. else{
  996. vc.isPhotoType = NO;
  997. }
  998. [self.navigationController pushViewController:vc animated:YES];
  999. }
  1000. else{
  1001. KWeakSelf
  1002. [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
  1003. [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
  1004. }];
  1005. }
  1006. }
  1007. #pragma mark 文件下载
  1008. - (void)gotoDownLoadFileFun
  1009. {
  1010. if(_didSelectListArr.count == 0){
  1011. [[iToast makeText:@""] show];
  1012. return;
  1013. }
  1014. NSMutableArray *arr = [NSMutableArray new];
  1015. for (getInstalledAppModel *dataModel in _didSelectListArr) {
  1016. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  1017. fileModel.fileType = @"apk";
  1018. fileModel.path = dataModel.path;
  1019. fileModel.name = dataModel.name;
  1020. if(dataModel.size > 0){
  1021. fileModel.length = dataModel.size;
  1022. }
  1023. else{
  1024. fileModel.length = dataModel.length;
  1025. }
  1026. //fileModel.time = dataModel.time;
  1027. [arr addObject:fileModel];
  1028. }
  1029. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1030. [self.navigationController pushViewController:vc animated:YES];
  1031. vc.isDownloadingType = YES;
  1032. [vc gotoDownloadFile:arr];
  1033. }
  1034. #pragma mark 删除图片
  1035. - (void)showDeleteAlearViewFun
  1036. {
  1037. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  1038. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  1039. KWeakSelf
  1040. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  1041. msg:tipStr
  1042. imageStr:nil
  1043. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1044. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  1045. didClickOk:^{
  1046. [weakSelf delFileListFun];
  1047. } didClickCancel:^{
  1048. }];
  1049. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1050. [self presentViewController:curAlretVC animated:YES completion:^{
  1051. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1052. }];
  1053. }
  1054. #pragma mark 删除文件数据
  1055. - (void)delFileListFun
  1056. {
  1057. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1058. NSMutableArray *pathArr = [NSMutableArray new];
  1059. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1060. [pathArr addObject:dataModel.path];
  1061. }
  1062. [paraDict setValue:pathArr forKey:@"path"];
  1063. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  1064. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  1065. KWeakSelf //@"delFile"
  1066. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1067. [weakSelf removeNewIndicator];
  1068. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1069. if(model && model.status == 0){
  1070. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  1071. [weakSelf didDeleteSucFun];
  1072. }
  1073. else{
  1074. }
  1075. } failure:^(NSError * _Nonnull error) {
  1076. [weakSelf removeNewIndicator];
  1077. }];
  1078. //数据埋点
  1079. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_delete"];
  1080. }
  1081. #pragma mark 删除成功
  1082. - (void)didDeleteSucFun
  1083. {
  1084. //删除最近文件
  1085. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  1086. [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
  1087. }
  1088. //2.删除已经获取到的网络数据
  1089. [self deleteNetDataByDeleteSucFun];
  1090. [_didSelectListArr removeAllObjects];
  1091. [self setEditTypeTitleFun];
  1092. }
  1093. #pragma mark 删除成功后 对应删除原来获取的网络数据
  1094. - (void)deleteNetDataByDeleteSucFun
  1095. {
  1096. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1097. for (getInstalledAppModel *model in _getUninstalledAppListMod.data) {
  1098. if (!model.isSelectType) {
  1099. [afterFilterArr addObject:model];
  1100. }
  1101. }
  1102. _getUninstalledAppListMod.data = (NSArray<getInstalledAppModel>*)afterFilterArr;
  1103. [self.tableView reloadData];
  1104. }
  1105. #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
  1106. - (void)deleteNetDataByFilePath:(NSString*)filePath
  1107. {
  1108. if(!filePath || filePath.length == 0){
  1109. return;
  1110. }
  1111. NSMutableArray *afterFilterArr = [NSMutableArray new];
  1112. for (getInstalledAppModel *model in _getInstalledAppListMod.data) {
  1113. if (![model.path isEqualToString:filePath]) {
  1114. [afterFilterArr addObject:model];
  1115. }
  1116. }
  1117. _getInstalledAppListMod.data = (NSArray<getInstalledAppModel>*)afterFilterArr;
  1118. [self.tableView reloadData];
  1119. }
  1120. #pragma mark 获取分享开关
  1121. -(void)queryShareSwitchFunFun
  1122. {
  1123. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1124. [paraDict setValue:@3 forKey:@"type"];
  1125. KWeakSelf
  1126. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  1127. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1128. if(queryShareMod){
  1129. self->canShareType = queryShareMod.data.configValue;
  1130. weakSelf.curEditTypeBottomView.isCanShareType = self->canShareType;
  1131. }
  1132. } failure:^(NSError * _Nonnull error) {
  1133. }];
  1134. }
  1135. #pragma mark 获取安装到TV开关
  1136. -(void)queryTVSwitchFunFun
  1137. {
  1138. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  1139. [paraDict setValue:@"tv_switch_button" forKey:@"configKey"];
  1140. KWeakSelf
  1141. [[netWorkManager shareInstance] CommonGetWithCallBackCode:querySwitchButton Parameters:paraDict success:^(id _Nonnull responseObject){
  1142. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  1143. if(queryShareMod){
  1144. self->canInstallTVType = queryShareMod.data.configValue;
  1145. weakSelf.curEditTypeBottomView.isCanInstallToTVType = self->canInstallTVType;
  1146. }
  1147. } failure:^(NSError * _Nonnull error) {
  1148. }];
  1149. }
  1150. #pragma mark 点击了已安装和未安装
  1151. - (void)didClickHeadTabButtonFun:(NSInteger)tag
  1152. {
  1153. if(tag == 1){
  1154. // _curInstalledAppListMod = _getInstalledAppListMod;
  1155. // self.curEditTypeBottomView.isCanDeleteType = NO;
  1156. isSecondTabType = NO;
  1157. }
  1158. else{
  1159. // _curInstalledAppListMod = _getUninstalledAppListMod;
  1160. // self.curEditTypeBottomView.isCanDeleteType = YES;
  1161. isSecondTabType = YES;
  1162. if (!_getUninstalledAppListMod) {
  1163. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  1164. }
  1165. }
  1166. //[_tableView reloadData];
  1167. [self RefreshAllUIFun];
  1168. }
  1169. #pragma mark 安装APP到TV
  1170. - (void)ClickInstallAPPToTVFun
  1171. {
  1172. [self showInstallTVAlearViewFun];
  1173. }
  1174. #pragma mark 弹框二次确认安装到TV
  1175. - (void)showInstallTVAlearViewFun
  1176. {
  1177. //NSInteger selectNum = _didSelectListArr.count;
  1178. NSString *titleStr = NSLocalizedString(@"alert_install_TV_title",nil);
  1179. NSString *tipStr1 = NSLocalizedString(@"alert_install_TV_msg_1",nil);
  1180. // NSString *tipStr2 = NSLocalizedString(@"alert_install_TV_msg_2",nil);
  1181. // NSString *tipStr3 = NSLocalizedString(@"alert_install_TV_msg_3",nil);
  1182. NSString * tipStr = tipStr1;//[[NSString alloc] initWithFormat:@"%@%ld%@%ld%@",tipStr1,selectNum,tipStr2,selectNum*15,tipStr3];
  1183. KWeakSelf
  1184. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  1185. msg:tipStr
  1186. imageStr:@""
  1187. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  1188. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  1189. didClickOk:^{
  1190. [[appToTVManager shareInstance] addAppToTVByList:weakSelf.didSelectListArr];
  1191. } didClickCancel:^{
  1192. }];
  1193. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1194. [self presentViewController:curAlretVC animated:YES completion:^{
  1195. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1196. }];
  1197. }
  1198. #pragma mark 点击了搜索
  1199. - (void)gotoSearchVCFun
  1200. {
  1201. NasSearchAppViewController *vc = [NasSearchAppViewController new];
  1202. vc.isCanDeleteType = self.curEditTypeBottomView.isCanDeleteType;
  1203. vc.totalAPPListModel = _curInstalledAppListMod;
  1204. [self.navigationController pushViewController:vc animated:YES];
  1205. }
  1206. #pragma mark 文件上传跳转上传记录
  1207. - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
  1208. {
  1209. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1210. [self.navigationController pushViewController:vc animated:YES];
  1211. vc.isUploadingType = YES;
  1212. [vc gotoUploadFileByFileApp:urls];
  1213. }
  1214. @end