previewImageOrVideoViewController.m 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  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 "downloadThumbnailManager.h"
  10. #import "downloadManager.h"
  11. #import "uploadFileRecordViewController.h"
  12. #import "UIScrollView+EmptyDataSet.h"
  13. #import "diskListBgView.h"
  14. #import "diskListTableView.h"
  15. #import "imageCollectionViewCell.h"
  16. #import "titleLabelReusableView.h"
  17. #import "editTypeHeadView.h"
  18. #import "editTypeBottomView.h"
  19. #import "editShareView.h"
  20. #import "previewToUploadFileView.h"
  21. #import "NASFilePicModel.h"
  22. #import "imageDetailsScrollViewController.h"
  23. @interface previewImageOrVideoViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  24. {
  25. UIButton *tapBtn;
  26. UIButton* rightTransferListButton;//传输列表
  27. UIView* rightRedView;
  28. BOOL hadUploadTaskType;
  29. BOOL hadDownloadTaskType;
  30. }
  31. @property (nonatomic, strong) UICollectionView *dataCollectionView;
  32. @property (strong, nonatomic) UILabel *MytitleLabel;
  33. @property (strong, nonatomic) UIImageView *selectTip;
  34. @property (nonatomic, strong) diskListBgView *diskListBgV;
  35. @property (nonatomic, strong) diskListTableView *diskListTableV;
  36. @property (nonatomic, strong) NSMutableArray*diskListArr;
  37. @property (nonatomic, copy) NSString *defaultDiskPath;
  38. @property(nonatomic,assign) BOOL isEditType;
  39. @property(nonatomic,strong) editTypeHeadView*curEditTypeHeadView;
  40. @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
  41. @property(nonatomic,strong) UIButton*uploadFileButton;
  42. //@property(nonatomic,strong) couldPhoneFileListModel *curCouldPhoneFileListMod;
  43. @property(nonatomic,strong) NASFilePicModel *curNASFilePicModel;
  44. @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
  45. @end
  46. @implementation previewImageOrVideoViewController
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. // Do any additional setup after loading the view.
  50. [self.toolBar setHidden:YES];
  51. [self.navigationBar setHidden:YES];
  52. [self.navBarBGView setHidden:NO];
  53. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  54. [self.view setBackgroundColor:[UIColor whiteColor]];
  55. [self drawAnyView];
  56. _didSelectListArr = [NSMutableArray new];
  57. }
  58. - (void)drawAnyView{
  59. [self initNavHeadUIFun];
  60. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  61. _curEditTypeHeadView.hidden = YES;
  62. [self.navBarBGView addSubview:_curEditTypeHeadView];
  63. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.left.mas_equalTo(0);
  65. make.right.mas_equalTo(0);
  66. make.bottom.mas_equalTo(0);
  67. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  68. }];
  69. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  70. KWeakSelf
  71. _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
  72. if(tag==1){
  73. [weakSelf userCancelEditTypeFun];
  74. }
  75. };
  76. _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
  77. [weakSelf didClickSelectAllButton:but];
  78. };
  79. _curEditTypeBottomView = [[editTypeBottomView alloc] init];
  80. _curEditTypeBottomView.hidden = YES;
  81. [self.view addSubview:_curEditTypeBottomView];
  82. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.left.mas_equalTo(0);
  84. make.right.mas_equalTo(0);
  85. make.bottom.mas_equalTo(0);
  86. make.height.mas_equalTo(60 + AdaptTabHeight);
  87. }];
  88. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  89. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  90. if(tag==1){
  91. [[iToast makeText:@"点击下载"] show];
  92. }
  93. else if(tag==2){
  94. [weakSelf gotoShareViewFun];
  95. }
  96. else if(tag==3){
  97. [[iToast makeText:@"点击删除"] show];
  98. }
  99. };
  100. [self.view addSubview:self.dataCollectionView];
  101. [self.dataCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.left.mas_equalTo(0);
  103. make.right.mas_equalTo(0);
  104. //make.bottom.mas_equalTo(-(safeArea));
  105. make.bottom.mas_equalTo(0);
  106. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  107. }];
  108. //大+号
  109. _uploadFileButton = [[UIButton alloc] init];
  110. [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
  111. [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
  112. [self.view addSubview:_uploadFileButton];
  113. [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.right.mas_equalTo(-15);
  115. make.width.mas_equalTo(52);
  116. make.height.mas_equalTo(52);
  117. make.bottom.mas_equalTo(-30 - AdaptTabHeight);
  118. }];
  119. NSMutableArray *arr = [NSMutableArray new];
  120. NSArray *diskList = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  121. if(diskList && [diskList isKindOfClass:[NSArray class]]){
  122. for (cloudPhoneExtraFileModel *model in diskList) {
  123. model.isCheckType = NO;
  124. [arr addObject:model];
  125. }
  126. }
  127. if(arr.count >0){
  128. cloudPhoneExtraFileModel *model = arr.firstObject;
  129. model.isCheckType = YES;
  130. _defaultDiskPath = model.extraPath;
  131. }
  132. _diskListArr = arr;
  133. [self setTitleAfterGetdiskFun];
  134. }
  135. - (void)initNavHeadUIFun
  136. {
  137. //title
  138. UILabel *titleLabel = [[UILabel alloc] init];
  139. titleLabel.textAlignment = NSTextAlignmentCenter;
  140. titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  141. titleLabel.textColor = [UIColor blackColor];
  142. titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  143. [self.navBarBGView addSubview:titleLabel];
  144. self.MytitleLabel = titleLabel;
  145. //selectTipImageView
  146. UIImageView *selectTip = [[UIImageView alloc] init];
  147. selectTip.image = [UIImage imageNamed:@"upload_image_arrow"];
  148. selectTip.translatesAutoresizingMaskIntoConstraints = NO;
  149. [self.navBarBGView addSubview:selectTip];
  150. self.selectTip = selectTip;
  151. tapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  152. tapBtn.backgroundColor = [UIColor clearColor];
  153. tapBtn.translatesAutoresizingMaskIntoConstraints = NO;
  154. [tapBtn addTarget:self action:@selector(selectDiskAction:) forControlEvents:UIControlEventTouchUpInside];
  155. [self.navBarBGView addSubview:tapBtn];
  156. [tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  157. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  158. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  159. make.width.mas_equalTo(100);
  160. make.height.mas_equalTo(30);
  161. }];
  162. [self setTitleLabelText:@""];
  163. rightTransferListButton = [[UIButton alloc] init];
  164. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  165. [rightTransferListButton addTarget:self action:@selector(didiClikRightButGotoTransferListFun:) forControlEvents:UIControlEventTouchUpInside];
  166. [self.navBarBGView addSubview:rightTransferListButton];
  167. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  168. make.width.mas_equalTo(40);
  169. make.height.mas_equalTo(40);
  170. make.right.mas_equalTo(-15);
  171. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  172. }];
  173. rightRedView = [[UIView alloc] init];
  174. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  175. [rightTransferListButton addSubview:rightRedView];
  176. rightRedView.layer.cornerRadius = 7;
  177. rightRedView.hidden = YES;
  178. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  179. make.width.mas_equalTo(14);
  180. make.height.mas_equalTo(14);
  181. make.right.mas_equalTo(0);
  182. make.top.mas_equalTo(6);
  183. }];
  184. }
  185. #pragma mark - 懒加载
  186. - (UICollectionView *)dataCollectionView{
  187. if (!_dataCollectionView) {
  188. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  189. // 设置item的行间距和列间距
  190. layout.minimumInteritemSpacing = 1;
  191. layout.minimumLineSpacing = 1;
  192. // 设置item的大小
  193. CGFloat itemW = ([UIScreen mainScreen].bounds.size.width - 10) /4 ;
  194. layout.itemSize = CGSizeMake(itemW, itemW);
  195. layout.headerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 40);
  196. //layout.footerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 40);
  197. // 设置每个分区的 上左下右 的内边距
  198. layout.sectionInset = UIEdgeInsetsMake(1, 1 ,1, 1);
  199. // 设置区头和区尾的大小
  200. layout.headerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 10);
  201. //layout.footerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 10);
  202. // 设置分区的头视图和尾视图 是否始终固定在屏幕上边和下边
  203. layout.sectionFootersPinToVisibleBounds = YES;
  204. //设置滚动条方向
  205. layout.scrollDirection = UICollectionViewScrollDirectionVertical;
  206. _dataCollectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
  207. _dataCollectionView.backgroundColor = [UIColor whiteColor];
  208. _dataCollectionView.scrollEnabled = YES;
  209. //注册cell
  210. [_dataCollectionView registerClass:[imageCollectionViewCell class] forCellWithReuseIdentifier:@"imageCollectionViewCell"];
  211. [_dataCollectionView registerClass:[titleLabelReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"titleLabelReusableView"];
  212. _dataCollectionView.delegate = self;
  213. _dataCollectionView.dataSource = self;
  214. //空数据引入第三方开源处理
  215. _dataCollectionView.emptyDataSetSource = self;
  216. _dataCollectionView.emptyDataSetDelegate = self;
  217. }
  218. return _dataCollectionView;
  219. }
  220. - (diskListBgView*)diskListBgV
  221. {
  222. if(!_diskListBgV){
  223. _diskListBgV = [[diskListBgView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
  224. _diskListBgV.hidden = YES;
  225. [self.view addSubview:_diskListBgV];
  226. KWeakSelf
  227. _diskListBgV.didTapWhitePlace = ^{
  228. [weakSelf hideDiskListVieFun];
  229. };
  230. [_diskListBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  231. make.left.mas_equalTo(0);
  232. make.bottom.mas_equalTo(0);
  233. make.right.mas_equalTo(0);
  234. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  235. }];
  236. [self.view addSubview:self.diskListTableV];
  237. self.diskListTableV.hidden = YES;
  238. [self.diskListTableV mas_makeConstraints:^(MASConstraintMaker *make) {
  239. make.left.mas_equalTo(0);
  240. make.height.mas_equalTo(3*70);
  241. make.right.mas_equalTo(0);
  242. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  243. }];
  244. self.diskListTableV.diskListArr = _diskListArr;
  245. self.diskListTableV.didClickDiskModel = ^(NSString * _Nonnull checkPath) {
  246. [weakSelf didCheckDiskFunByPath:checkPath];
  247. };
  248. }
  249. return _diskListBgV;
  250. }
  251. - (UITableView *)diskListTableV{
  252. if (!_diskListTableV) {
  253. _diskListTableV = [[diskListTableView alloc] init];
  254. //
  255. }
  256. return _diskListTableV;
  257. }
  258. #pragma mark 选中磁盘
  259. - (void)didCheckDiskFunByPath:(NSString*)pathStr
  260. {
  261. if(self.defaultDiskPath
  262. && self.defaultDiskPath.length>0
  263. && ![self.defaultDiskPath isEqualToString:pathStr]){
  264. //切换硬盘了 取消全选
  265. //_rightSelectAllButton.selected = YES;
  266. //[self didClickSelectAllButton:_rightSelectAllButton];
  267. }
  268. self.defaultDiskPath = pathStr;
  269. //[self searchFileListFun];
  270. [self setTitleAfterGetdiskFun];
  271. [self hideDiskListVieFun];
  272. }
  273. #pragma mark - 瀑布流委托
  274. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  275. if(_curNASFilePicModel){
  276. return _curNASFilePicModel.data.fileList.count;
  277. }
  278. return 1;
  279. }
  280. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  281. if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count >section){
  282. NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
  283. return timeArrModel.list.count;
  284. }
  285. return 0;
  286. }
  287. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  288. {
  289. __block NSInteger row = indexPath.row;
  290. __block NSInteger section = indexPath.section;
  291. //创建item 从缓存池中拿 Item
  292. imageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"imageCollectionViewCell" forIndexPath:indexPath];
  293. if(!cell){
  294. cell = [[imageCollectionViewCell alloc] init];
  295. }
  296. if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
  297. NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
  298. if (timeArrModel.list.count > row) {
  299. NASFilePicDataArrModel * dataModel = timeArrModel.list[row];
  300. cell.isEditType = _isEditType;
  301. if(_isPhotoType){
  302. cell.fileType = @"pic";
  303. }
  304. else{
  305. cell.fileType = @"video";
  306. }
  307. cell.curFileModel = dataModel;
  308. KWeakSelf
  309. cell.didClckSelectBut = ^(BOOL selectType){
  310. if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
  311. [weakSelf userCheckFilePreviewByRow:row];
  312. }
  313. };
  314. cell.didClickEditType = ^(BOOL editType) {
  315. [weakSelf setViewEditTypeFun];
  316. };
  317. }
  318. }
  319. return cell;
  320. }
  321. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  322. if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
  323. NSInteger section = indexPath.section;
  324. titleLabelReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"titleLabelReusableView" forIndexPath:indexPath];
  325. if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
  326. NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
  327. headerView.titlelabel.text = timeArrModel.time;
  328. }
  329. return headerView;
  330. }
  331. return nil;
  332. }
  333. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
  334. return CGSizeMake([UIScreen mainScreen].bounds.size.width, 40);
  335. }
  336. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  337. {
  338. NSInteger row = indexPath.row;
  339. NSInteger section = indexPath.section;
  340. if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
  341. NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
  342. if (timeArrModel.list.count > row) {
  343. //NASFilePicDataArrModel * dataModel = timeArrModel.list[row];
  344. if(_isPhotoType){
  345. [self didClickPicDetailsWithSection:section withRow:row];
  346. }
  347. }
  348. }
  349. }
  350. #pragma mark 空数据
  351. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  352. NSString *imageName = @"common_no_data_pic";
  353. return [UIImage imageNamed:imageName];
  354. }
  355. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  356. NSString *text = NSLocalizedString(@"File_download_file_no_data",nil);
  357. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  358. NSForegroundColorAttributeName: HW999999Color};
  359. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  360. }
  361. //调整图片位置
  362. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  363. return -150;
  364. }
  365. //ios端:
  366. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  367. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  368. //ios支持图片格式: (SVG 不支持)
  369. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  370. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  371. - (BOOL)userCheckFileModel:(NASFilePicDataArrModel*)fileModel withShowTip:(BOOL)canShow{
  372. // NSString*name = [fileModel.name lowercaseString];
  373. // NSArray *nameArr = [name componentsSeparatedByString:@"."];
  374. // if(nameArr.count >0 && !_isPhotoType){
  375. // BOOL canDownLoadType = NO;
  376. //
  377. // NSString *lastName = nameArr.lastObject;
  378. // if([lastName isEqualToString:@"mp4"]
  379. // ||[lastName isEqualToString:@"mov"]
  380. // ||[lastName isEqualToString:@"3gp"]
  381. // ||[lastName isEqualToString:@"m4v"]){
  382. // canDownLoadType = YES;
  383. // }
  384. //
  385. // if(!canDownLoadType){
  386. // if(canShow){
  387. // [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  388. // }
  389. //
  390. // return NO;
  391. // }
  392. // }
  393. //
  394. // if(nameArr.count >0 && _isPhotoType){
  395. // BOOL canDownLoadType = NO;
  396. // //JPG 、PNG、GIF、TIFF、BMP
  397. // NSString *lastName = nameArr.lastObject;
  398. // if([lastName isEqualToString:@"jpg"]
  399. // ||[lastName isEqualToString:@"png"]
  400. // ||[lastName isEqualToString:@"gif"]
  401. // ||[lastName isEqualToString:@"tiff"]
  402. // ||[lastName isEqualToString:@"bmp"]
  403. // ||[lastName isEqualToString:@"heic"]
  404. // ||[lastName isEqualToString:@"jpeg"]
  405. // ||[lastName isEqualToString:@"heif"]){
  406. // canDownLoadType = YES;
  407. // }
  408. //
  409. // if(!canDownLoadType){
  410. // if(canShow){
  411. // [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  412. // }
  413. // return NO;
  414. // }
  415. // }
  416. return YES;
  417. }
  418. #pragma mark 用户长按图片进入编辑
  419. - (void)setViewEditTypeFun
  420. {
  421. _isEditType = YES;
  422. [_dataCollectionView reloadData];
  423. _curEditTypeHeadView.hidden = NO;
  424. _curEditTypeBottomView.hidden = NO;
  425. _uploadFileButton.hidden = YES;
  426. [self.dataCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  427. make.left.mas_equalTo(0);
  428. make.right.mas_equalTo(0);
  429. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  430. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  431. }];
  432. }
  433. #pragma mark 用户取消编辑编辑
  434. - (void)userCancelEditTypeFun
  435. {
  436. _isEditType = NO;
  437. [_dataCollectionView reloadData];
  438. _curEditTypeHeadView.hidden = YES;
  439. _curEditTypeBottomView.hidden = YES;
  440. _uploadFileButton.hidden = NO;
  441. [self.dataCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  442. make.left.mas_equalTo(0);
  443. make.right.mas_equalTo(0);
  444. make.bottom.mas_equalTo(0);
  445. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  446. }];
  447. }
  448. - (void)userCheckFilePreviewByRow:(NSInteger)row
  449. {
  450. // if(row < _curCouldPhoneFileListMod.data.list.count){
  451. // couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  452. //
  453. // if(fileModel.isSelectType){
  454. // [_didSelectListArr removeObject:fileModel];
  455. // }
  456. // else{
  457. // [_didSelectListArr addObject:fileModel];
  458. // }
  459. //
  460. // fileModel.isSelectType = !fileModel.isSelectType;
  461. // //[self.tableView reloadData];
  462. // //[self.dataCollectionView reloadData];
  463. // [self setEditTypeTitleFun];
  464. // }
  465. }
  466. - (void)didClickSelectAllButton:(UIButton*)button
  467. {
  468. //button.selected = !button.selected;
  469. BOOL isNeedShowTip = NO;
  470. [_didSelectListArr removeAllObjects];
  471. // for (couldPhoneFileModel* fileModel in _curCouldPhoneFileListMod.data.list) {
  472. //
  473. // if(!button.selected){
  474. // fileModel.isSelectType = button.selected;
  475. // }
  476. // else{
  477. // [_didSelectListArr addObject:fileModel];
  478. // if([self userCheckFileModel:fileModel withShowTip:NO]){
  479. // fileModel.isSelectType = button.selected;
  480. // }
  481. // else{
  482. // isNeedShowTip = YES;
  483. // }
  484. // }
  485. //
  486. // }
  487. if(isNeedShowTip){
  488. if(_isPhotoType){
  489. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  490. }
  491. else{
  492. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  493. }
  494. }
  495. //[self.tableView reloadData];
  496. [self.dataCollectionView reloadData];
  497. [self setEditTypeTitleFun];
  498. }
  499. #pragma mark 设置选中标题
  500. - (void)setEditTypeTitleFun
  501. {
  502. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  503. }
  504. #pragma mark 用户点击分享
  505. - (void)gotoShareViewFun
  506. {
  507. editShareView *editShareV = [[editShareView alloc] init];
  508. [self.view addSubview:editShareV];
  509. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  510. make.left.mas_equalTo(0);
  511. make.right.mas_equalTo(0);
  512. make.bottom.mas_equalTo(0);
  513. make.top.mas_equalTo(0);
  514. }];
  515. }
  516. #pragma mark 用户点击上传文件
  517. - (void)userDidClickUploadViewFun
  518. {
  519. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  520. [self.view addSubview:previewToUploadFileV];
  521. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  522. make.left.mas_equalTo(0);
  523. make.right.mas_equalTo(0);
  524. make.bottom.mas_equalTo(0);
  525. make.top.mas_equalTo(0);
  526. }];
  527. }
  528. #pragma mark 设置标题
  529. - (void)setTitleLabelText:(NSString*)title
  530. {
  531. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  532. if(diskNameArr && diskNameArr.count >= 2){
  533. NSString *name = diskNameArr.lastObject;
  534. if(name.length == 0)
  535. {
  536. name = diskNameArr[diskNameArr.count -2];
  537. }
  538. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  539. }
  540. self.MytitleLabel.text = title;
  541. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  542. curWidth += 20;
  543. //HLog(@"title w:%f",curWidth);
  544. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  545. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  546. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  547. make.width.mas_equalTo(curWidth);
  548. make.height.mas_equalTo(30);
  549. }];
  550. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  551. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  552. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  553. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  554. make.width.mas_equalTo(15);
  555. make.height.mas_equalTo(15);
  556. }];
  557. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  558. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  559. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  560. make.width.mas_equalTo(curWidth+15);
  561. make.height.mas_equalTo(30);
  562. }];
  563. }
  564. #pragma mark 选择硬盘
  565. - (void)selectDiskAction:(UIButton*)but
  566. {
  567. if(self.diskListBgV.hidden){
  568. [self showDiskListVieFun];
  569. }
  570. else{
  571. [self hideDiskListVieFun];
  572. }
  573. }
  574. - (void)showDiskListVieFun
  575. {
  576. self.diskListBgV.hidden = NO;
  577. self.diskListTableV.hidden = NO;
  578. [UIView animateWithDuration:0.3 animations:^{
  579. CGRect rect = self.diskListTableV.frame;
  580. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  581. self.diskListTableV.frame = rect;
  582. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  583. }];
  584. }
  585. - (void)hideDiskListVieFun
  586. {
  587. self.diskListBgV.hidden = YES;
  588. [UIView animateWithDuration:0.3 animations:^{
  589. self.diskListTableV.hidden = YES;
  590. self.selectTip.transform = CGAffineTransformIdentity;
  591. }completion:^(BOOL finished) {
  592. CGRect rect = self.diskListTableV.frame;
  593. rect.origin.y = 0;
  594. self.diskListTableV.frame = rect;
  595. }];
  596. }
  597. #pragma mark 设置标题
  598. - (void)setTitleAfterGetdiskFun
  599. {
  600. if(_isPhotoType){
  601. //self.titleLabel.text = NSLocalizedString(@"my_set_no_image_upload",nil) ;
  602. [self setTitleLabelText:NSLocalizedString(@"my_set_no_image_upload",nil)];
  603. }
  604. else{
  605. //self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
  606. [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
  607. }
  608. }
  609. - (void)viewWillAppear:(BOOL)animated
  610. {
  611. [super viewWillAppear:animated];
  612. }
  613. - (void)viewDidAppear:(BOOL)animated{
  614. [super viewDidAppear:animated];
  615. [self showDownloadTipFun];
  616. [self checkFileTransferTask];
  617. if(!_curNASFilePicModel){
  618. [self getFileListFun];
  619. }
  620. }
  621. - (void)viewWillDisappear:(BOOL)animated{
  622. [super viewWillDisappear:animated];
  623. //[self removeNewIndicator];
  624. [self removeNewIndicatorHaveStr];
  625. }
  626. - (void)gotoDownloadloadFileRecordFun
  627. {
  628. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  629. [self.navigationController pushViewController:vc animated:YES];
  630. vc.isDownloadingType = YES;
  631. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  632. }
  633. - (void)showDownloadTipFun
  634. {
  635. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  636. if(didReadUploadTipType){
  637. return;
  638. }
  639. //KWeakSelf
  640. /*弹窗提示恢复出厂*/
  641. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  642. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  643. imageStr:nil
  644. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  645. okTitle:nil
  646. isOkBtnHighlight:NO
  647. didClickOk:^{
  648. } didClickCancel:^{
  649. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  650. }];
  651. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  652. [self presentViewController:nextVC animated:YES completion:^{
  653. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  654. }];
  655. }
  656. - (void)checkFileTransferTask
  657. {//有个偶现的闪退在BGFMDB
  658. [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  659. self->hadUploadTaskType = isSuccess;
  660. [self setRightButtonRedTypeFun];
  661. }];
  662. KWeakSelf
  663. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  664. [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  665. self->hadDownloadTaskType = isSuccess;
  666. [weakSelf setRightButtonRedTypeFun];
  667. }];
  668. });
  669. }
  670. - (void)setRightButtonRedTypeFun
  671. {
  672. mainBlock(^{
  673. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  674. self->rightRedView.hidden = NO;
  675. }
  676. else{
  677. self->rightRedView.hidden = YES;
  678. }
  679. });
  680. }
  681. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  682. {
  683. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  684. [self.navigationController pushViewController:vc animated:YES];
  685. }
  686. #pragma mark 获取文件数据
  687. - (void)getFileListFun
  688. {
  689. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  690. if(_isPhotoType){
  691. [paraDict setValue:@"pic" forKey:@"type"];
  692. }
  693. else{
  694. [paraDict setValue:@"video" forKey:@"type"];
  695. }
  696. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  697. if(diskNameArr && diskNameArr.count >= 2){
  698. NSString *name = diskNameArr.lastObject;
  699. if(name.length == 0)
  700. {
  701. name = diskNameArr[diskNameArr.count -2];
  702. }
  703. [paraDict setValue:name forKey:@"path"];
  704. }
  705. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  706. KWeakSelf
  707. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileListByDay" Parameters:paraDict success:^(id _Nonnull responseObject) {
  708. [weakSelf removeNewIndicatorHaveStr];
  709. weakSelf.curNASFilePicModel = [[NASFilePicModel alloc] initWithDictionary:responseObject error:nil];
  710. [weakSelf.dataCollectionView reloadData];
  711. } failure:^(NSError * _Nonnull error) {
  712. [weakSelf removeNewIndicatorHaveStr];
  713. }];
  714. }
  715. #pragma mark 点击图片详情
  716. - (void)didClickPicDetailsWithSection:(NSInteger)section withRow:(NSInteger)row{
  717. if(_curNASFilePicModel){
  718. NSMutableArray *totalArr = [NSMutableArray new];
  719. NSInteger index = 0;
  720. for (int i=0; i<_curNASFilePicModel.data.fileList.count; i++) {
  721. NASFilePicTimeArrModel *timeModel = _curNASFilePicModel.data.fileList[i];
  722. if(i == section){
  723. index = totalArr.count + row;
  724. }
  725. [totalArr addObjectsFromArray:timeModel.list];
  726. }
  727. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  728. vc.index = index;
  729. vc.totalDataArr = totalArr;
  730. [self.navigationController pushViewController:vc animated:YES];
  731. }
  732. }
  733. @end