previewImageOrVideoViewController.m 48 KB

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