previewImageOrVideoViewController.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  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. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchFileListDoneFun:) name:searchFileListDoneNotification object:nil];
  53. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didDownloadOneFileFun) name:downloadThumbnailDoneOneNotification object:nil];
  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. return 1;
  275. }
  276. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  277. if(!_curCouldPhoneFileListMod){
  278. return 0;
  279. }
  280. return _curCouldPhoneFileListMod.data.list.count;
  281. }
  282. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  283. {
  284. __block NSInteger row = indexPath.row;
  285. //创建item 从缓存池中拿 Item
  286. imageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"imageCollectionViewCell" forIndexPath:indexPath];
  287. if(!cell){
  288. cell = [[imageCollectionViewCell alloc] init];
  289. }
  290. if(row < _curCouldPhoneFileListMod.data.list.count){
  291. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  292. cell.isEditType = _isEditType;
  293. cell.curFileModel = fileModel;
  294. KWeakSelf
  295. cell.didClckSelectBut = ^(BOOL selectType){
  296. if([weakSelf userCheckFileModel:fileModel withShowTip:YES]){
  297. [weakSelf userCheckFilePreviewByRow:row];
  298. }
  299. };
  300. cell.didClickEditType = ^(BOOL editType) {
  301. [self setViewEditTypeFun];
  302. };
  303. }
  304. return cell;
  305. }
  306. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  307. if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
  308. titleLabelReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"titleLabelReusableView" forIndexPath:indexPath];
  309. headerView.titlelabel.text = @"2025年13月32号";
  310. return headerView;
  311. }
  312. return nil;
  313. }
  314. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
  315. return CGSizeMake([UIScreen mainScreen].bounds.size.width, 40);
  316. }
  317. #pragma mark 空数据
  318. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  319. NSString *imageName = @"uploadFile_noData";
  320. return [UIImage imageNamed:imageName];
  321. }
  322. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  323. NSString *text = NSLocalizedString(@"File_download_file_no_data",nil);
  324. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  325. NSForegroundColorAttributeName: HW999999Color};
  326. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  327. }
  328. //调整图片位置
  329. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  330. return -150;
  331. }
  332. //ios端:
  333. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  334. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  335. //ios支持图片格式: (SVG 不支持)
  336. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  337. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  338. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  339. NSString*name = [fileModel.name lowercaseString];
  340. NSArray *nameArr = [name componentsSeparatedByString:@"."];
  341. if(nameArr.count >0 && !_isPhotoType){
  342. BOOL canDownLoadType = NO;
  343. NSString *lastName = nameArr.lastObject;
  344. if([lastName isEqualToString:@"mp4"]
  345. ||[lastName isEqualToString:@"mov"]
  346. ||[lastName isEqualToString:@"3gp"]
  347. ||[lastName isEqualToString:@"m4v"]){
  348. canDownLoadType = YES;
  349. }
  350. if(!canDownLoadType){
  351. if(canShow){
  352. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  353. }
  354. return NO;
  355. }
  356. }
  357. if(nameArr.count >0 && _isPhotoType){
  358. BOOL canDownLoadType = NO;
  359. //JPG 、PNG、GIF、TIFF、BMP
  360. NSString *lastName = nameArr.lastObject;
  361. if([lastName isEqualToString:@"jpg"]
  362. ||[lastName isEqualToString:@"png"]
  363. ||[lastName isEqualToString:@"gif"]
  364. ||[lastName isEqualToString:@"tiff"]
  365. ||[lastName isEqualToString:@"bmp"]
  366. ||[lastName isEqualToString:@"heic"]
  367. ||[lastName isEqualToString:@"jpeg"]
  368. ||[lastName isEqualToString:@"heif"]){
  369. canDownLoadType = YES;
  370. }
  371. if(!canDownLoadType){
  372. if(canShow){
  373. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  374. }
  375. return NO;
  376. }
  377. }
  378. return YES;
  379. }
  380. #pragma mark 用户长按图片进入编辑
  381. - (void)setViewEditTypeFun
  382. {
  383. _isEditType = YES;
  384. [_dataCollectionView reloadData];
  385. _curEditTypeHeadView.hidden = NO;
  386. _curEditTypeBottomView.hidden = NO;
  387. _uploadFileButton.hidden = YES;
  388. [self.dataCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  389. make.left.mas_equalTo(0);
  390. make.right.mas_equalTo(0);
  391. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  392. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  393. }];
  394. }
  395. #pragma mark 用户取消编辑编辑
  396. - (void)userCancelEditTypeFun
  397. {
  398. _isEditType = NO;
  399. [_dataCollectionView reloadData];
  400. _curEditTypeHeadView.hidden = YES;
  401. _curEditTypeBottomView.hidden = YES;
  402. _uploadFileButton.hidden = NO;
  403. [self.dataCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  404. make.left.mas_equalTo(0);
  405. make.right.mas_equalTo(0);
  406. make.bottom.mas_equalTo(0);
  407. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  408. }];
  409. }
  410. - (void)userCheckFilePreviewByRow:(NSInteger)row
  411. {
  412. if(row < _curCouldPhoneFileListMod.data.list.count){
  413. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  414. if(fileModel.isSelectType){
  415. [_didSelectListArr removeObject:fileModel];
  416. }
  417. else{
  418. [_didSelectListArr addObject:fileModel];
  419. }
  420. fileModel.isSelectType = !fileModel.isSelectType;
  421. //[self.tableView reloadData];
  422. //[self.dataCollectionView reloadData];
  423. [self setEditTypeTitleFun];
  424. }
  425. }
  426. - (void)didClickSelectAllButton:(UIButton*)button
  427. {
  428. //button.selected = !button.selected;
  429. BOOL isNeedShowTip = NO;
  430. [_didSelectListArr removeAllObjects];
  431. for (couldPhoneFileModel* fileModel in _curCouldPhoneFileListMod.data.list) {
  432. if(!button.selected){
  433. fileModel.isSelectType = button.selected;
  434. }
  435. else{
  436. [_didSelectListArr addObject:fileModel];
  437. if([self userCheckFileModel:fileModel withShowTip:NO]){
  438. fileModel.isSelectType = button.selected;
  439. }
  440. else{
  441. isNeedShowTip = YES;
  442. }
  443. }
  444. }
  445. if(isNeedShowTip){
  446. if(_isPhotoType){
  447. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  448. }
  449. else{
  450. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  451. }
  452. }
  453. //[self.tableView reloadData];
  454. [self.dataCollectionView reloadData];
  455. [self setEditTypeTitleFun];
  456. }
  457. #pragma mark 设置选中标题
  458. - (void)setEditTypeTitleFun
  459. {
  460. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  461. }
  462. #pragma mark 用户点击分享
  463. - (void)gotoShareViewFun
  464. {
  465. editShareView *editShareV = [[editShareView alloc] init];
  466. [self.view addSubview:editShareV];
  467. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  468. make.left.mas_equalTo(0);
  469. make.right.mas_equalTo(0);
  470. make.bottom.mas_equalTo(0);
  471. make.top.mas_equalTo(0);
  472. }];
  473. }
  474. #pragma mark 用户点击上传文件
  475. - (void)userDidClickUploadViewFun
  476. {
  477. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  478. [self.view addSubview:previewToUploadFileV];
  479. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  480. make.left.mas_equalTo(0);
  481. make.right.mas_equalTo(0);
  482. make.bottom.mas_equalTo(0);
  483. make.top.mas_equalTo(0);
  484. }];
  485. }
  486. #pragma mark 设置标题
  487. - (void)setTitleLabelText:(NSString*)title
  488. {
  489. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  490. if(diskNameArr && diskNameArr.count >= 2){
  491. NSString *name = diskNameArr.lastObject;
  492. if(name.length == 0)
  493. {
  494. name = diskNameArr[diskNameArr.count -2];
  495. }
  496. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  497. }
  498. self.MytitleLabel.text = title;
  499. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  500. curWidth += 20;
  501. //HLog(@"title w:%f",curWidth);
  502. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  503. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  504. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  505. make.width.mas_equalTo(curWidth);
  506. make.height.mas_equalTo(30);
  507. }];
  508. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  509. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  510. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  511. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  512. make.width.mas_equalTo(15);
  513. make.height.mas_equalTo(15);
  514. }];
  515. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  516. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  517. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  518. make.width.mas_equalTo(curWidth+15);
  519. make.height.mas_equalTo(30);
  520. }];
  521. }
  522. #pragma mark 选择硬盘
  523. - (void)selectDiskAction:(UIButton*)but
  524. {
  525. if(self.diskListBgV.hidden){
  526. [self showDiskListVieFun];
  527. }
  528. else{
  529. [self hideDiskListVieFun];
  530. }
  531. }
  532. - (void)showDiskListVieFun
  533. {
  534. self.diskListBgV.hidden = NO;
  535. self.diskListTableV.hidden = NO;
  536. [UIView animateWithDuration:0.3 animations:^{
  537. CGRect rect = self.diskListTableV.frame;
  538. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  539. self.diskListTableV.frame = rect;
  540. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  541. }];
  542. }
  543. - (void)hideDiskListVieFun
  544. {
  545. self.diskListBgV.hidden = YES;
  546. [UIView animateWithDuration:0.3 animations:^{
  547. self.diskListTableV.hidden = YES;
  548. self.selectTip.transform = CGAffineTransformIdentity;
  549. }completion:^(BOOL finished) {
  550. CGRect rect = self.diskListTableV.frame;
  551. rect.origin.y = 0;
  552. self.diskListTableV.frame = rect;
  553. }];
  554. }
  555. #pragma mark 设置标题
  556. - (void)setTitleAfterGetdiskFun
  557. {
  558. if(_isPhotoType){
  559. //self.titleLabel.text = NSLocalizedString(@"my_set_no_image_upload",nil) ;
  560. [self setTitleLabelText:NSLocalizedString(@"my_set_no_image_upload",nil)];
  561. }
  562. else{
  563. //self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
  564. [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
  565. }
  566. [self searchFileListFun];
  567. }
  568. - (void)viewWillAppear:(BOOL)animated
  569. {
  570. [super viewWillAppear:animated];
  571. }
  572. - (void)viewDidAppear:(BOOL)animated{
  573. [super viewDidAppear:animated];
  574. [self showDownloadTipFun];
  575. [self checkFileTransferTask];
  576. }
  577. - (void)viewWillDisappear:(BOOL)animated{
  578. [super viewWillDisappear:animated];
  579. //[self removeNewIndicator];
  580. [self removeNewIndicatorHaveStr];
  581. }
  582. - (void)searchFileListFun
  583. {
  584. NSMutableDictionary *dict = [NSMutableDictionary new];
  585. NSNumber *curNum = [NSNumber numberWithBool:_isPhotoType];
  586. [dict setObject:curNum forKey:@"type"];
  587. if(!_defaultDiskPath){
  588. _defaultDiskPath = @"";
  589. }
  590. [dict setObject:_defaultDiskPath forKey:@"path"];
  591. [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListBeginNotification object:dict];/*发送通知*/
  592. //[self showNewIndicatorWithCanBack:YES canTouch:NO];
  593. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  594. }
  595. - (void)searchFileListDoneFun:(NSNotification*)notification
  596. {
  597. //[self removeNewIndicator];
  598. [self removeNewIndicatorHaveStr];
  599. NSDictionary *dataDict = [notification object];
  600. if(!dataDict || ![dataDict isKindOfClass:[NSDictionary class]]){
  601. return;
  602. }
  603. _curCouldPhoneFileListMod = [[couldPhoneFileListModel alloc] initWithDictionary:dataDict error:nil];
  604. NSMutableArray *filterArr = [NSMutableArray new];
  605. for (couldPhoneFileModel*model in _curCouldPhoneFileListMod.data.list) {
  606. //if(model.length > 1024)
  607. if(model.length > 1024*50)
  608. {
  609. [filterArr addObject:model];
  610. }
  611. }
  612. _curCouldPhoneFileListMod.data.list = filterArr;
  613. //[self.tableView reloadData];
  614. [self.dataCollectionView reloadData];
  615. //这个要做判断 不能为空
  616. [self gotoDownThumbnailManagerFun];
  617. }
  618. #pragma mark 去下载缩略图
  619. - (void)gotoDownThumbnailManagerFun
  620. {
  621. // if(_curCouldPhoneFileListMod.data.list && _curCouldPhoneFileListMod.data.list.count >0){
  622. // [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailWith:_curCouldPhoneFileListMod.data.list];
  623. // }
  624. }
  625. - (void)gotoDownloadloadFileRecordFun
  626. {
  627. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  628. [self.navigationController pushViewController:vc animated:YES];
  629. vc.isDownloadingType = YES;
  630. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  631. }
  632. - (void)showDownloadTipFun
  633. {
  634. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  635. if(didReadUploadTipType){
  636. return;
  637. }
  638. //KWeakSelf
  639. /*弹窗提示恢复出厂*/
  640. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  641. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  642. imageStr:nil
  643. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  644. okTitle:nil
  645. isOkBtnHighlight:NO
  646. didClickOk:^{
  647. } didClickCancel:^{
  648. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  649. }];
  650. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  651. [self presentViewController:nextVC animated:YES completion:^{
  652. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  653. }];
  654. }
  655. - (void)didDownloadOneFileFun
  656. {
  657. mainBlock(^{
  658. //[self.tableView reloadData];
  659. [self.dataCollectionView reloadData];
  660. });
  661. }
  662. - (void)checkFileTransferTask
  663. {//有个偶现的闪退在BGFMDB
  664. [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  665. self->hadUploadTaskType = isSuccess;
  666. [self setRightButtonRedTypeFun];
  667. }];
  668. KWeakSelf
  669. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  670. [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  671. self->hadDownloadTaskType = isSuccess;
  672. [weakSelf setRightButtonRedTypeFun];
  673. }];
  674. });
  675. }
  676. - (void)setRightButtonRedTypeFun
  677. {
  678. mainBlock(^{
  679. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  680. self->rightRedView.hidden = NO;
  681. }
  682. else{
  683. self->rightRedView.hidden = YES;
  684. }
  685. });
  686. }
  687. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  688. {
  689. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  690. [self.navigationController pushViewController:vc animated:YES];
  691. }
  692. @end