previewImageOrVideoViewController.m 28 KB

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