previewImageOrVideoViewController.m 28 KB

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