previewImageOrVideoViewController.m 27 KB

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