previewAudioOrDocumentViewController.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. //
  2. // previewAudioOrDocumentViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/14.
  6. //
  7. #import "previewAudioOrDocumentViewController.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 "downLoadPreViewCell.h"
  16. #import "editTypeHeadView.h"
  17. #import "editTypeBottomView.h"
  18. #import "editShareView.h"
  19. #import "previewToUploadFileView.h"
  20. @interface previewAudioOrDocumentViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  21. {
  22. UIButton *tapBtn;
  23. UIButton* rightTransferListButton;//传输列表
  24. UIView* rightRedView;
  25. BOOL hadUploadTaskType;
  26. BOOL hadDownloadTaskType;
  27. }
  28. @property (nonatomic, strong) UITableView *tableView;
  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) UIButton*uploadFileButton;
  39. @property(nonatomic,strong) couldPhoneFileListModel *curCouldPhoneFileListMod;
  40. @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
  41. @end
  42. @implementation previewAudioOrDocumentViewController
  43. - (void)viewDidLoad {
  44. [super viewDidLoad];
  45. // Do any additional setup after loading the view.
  46. [self.toolBar setHidden:YES];
  47. [self.navigationBar setHidden:YES];
  48. [self.navBarBGView setHidden:NO];
  49. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  50. [self.view setBackgroundColor:[UIColor whiteColor]];
  51. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchFileListDoneFun:) name:searchFileListDoneNotification object:nil];
  52. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didDownloadOneFileFun) name:downloadThumbnailDoneOneNotification object:nil];
  53. [self drawAnyView];
  54. _didSelectListArr = [NSMutableArray new];
  55. }
  56. - (void)drawAnyView{
  57. [self initNavHeadUIFun];
  58. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  59. _curEditTypeHeadView.hidden = YES;
  60. [self.navBarBGView addSubview:_curEditTypeHeadView];
  61. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.mas_equalTo(0);
  63. make.right.mas_equalTo(0);
  64. make.bottom.mas_equalTo(0);
  65. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  66. }];
  67. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  68. KWeakSelf
  69. _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
  70. if(tag==1){
  71. [weakSelf userCancelEditTypeFun];
  72. }
  73. };
  74. _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
  75. [weakSelf didClickSelectAllButton:but];
  76. };
  77. _curEditTypeBottomView = [[editTypeBottomView alloc] init];
  78. _curEditTypeBottomView.hidden = YES;
  79. [self.view addSubview:_curEditTypeBottomView];
  80. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.mas_equalTo(0);
  82. make.right.mas_equalTo(0);
  83. make.bottom.mas_equalTo(0);
  84. make.height.mas_equalTo(60 + AdaptTabHeight);
  85. }];
  86. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  87. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  88. if(tag==1){
  89. [[iToast makeText:@"点击下载"] show];
  90. }
  91. else if(tag==2){
  92. [weakSelf gotoShareViewFun];
  93. }
  94. else if(tag==3){
  95. [[iToast makeText:@"点击删除"] show];
  96. }
  97. };
  98. [self.view addSubview:self.tableView];
  99. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.left.mas_equalTo(0);
  101. make.right.mas_equalTo(0);
  102. //make.bottom.mas_equalTo(-(safeArea));
  103. make.bottom.mas_equalTo(0);
  104. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  105. }];
  106. //大+号
  107. _uploadFileButton = [[UIButton alloc] init];
  108. [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
  109. [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
  110. [self.view addSubview:_uploadFileButton];
  111. [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.right.mas_equalTo(-15);
  113. make.width.mas_equalTo(52);
  114. make.height.mas_equalTo(52);
  115. make.bottom.mas_equalTo(-30 - AdaptTabHeight);
  116. }];
  117. NSMutableArray *arr = [NSMutableArray new];
  118. NSArray *diskList = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  119. if(diskList && [diskList isKindOfClass:[NSArray class]]){
  120. for (cloudPhoneExtraFileModel *model in diskList) {
  121. model.isCheckType = NO;
  122. [arr addObject:model];
  123. }
  124. }
  125. if(arr.count >0){
  126. cloudPhoneExtraFileModel *model = arr.firstObject;
  127. model.isCheckType = YES;
  128. _defaultDiskPath = model.extraPath;
  129. }
  130. _diskListArr = arr;
  131. [self setTitleAfterGetdiskFun];
  132. }
  133. - (void)initNavHeadUIFun
  134. {
  135. //title
  136. UILabel *titleLabel = [[UILabel alloc] init];
  137. titleLabel.textAlignment = NSTextAlignmentCenter;
  138. titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  139. titleLabel.textColor = [UIColor blackColor];
  140. titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  141. [self.navBarBGView addSubview:titleLabel];
  142. self.MytitleLabel = titleLabel;
  143. //selectTipImageView
  144. UIImageView *selectTip = [[UIImageView alloc] init];
  145. selectTip.image = [UIImage imageNamed:@"upload_image_arrow"];
  146. selectTip.translatesAutoresizingMaskIntoConstraints = NO;
  147. [self.navBarBGView addSubview:selectTip];
  148. self.selectTip = selectTip;
  149. tapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  150. tapBtn.backgroundColor = [UIColor clearColor];
  151. tapBtn.translatesAutoresizingMaskIntoConstraints = NO;
  152. [tapBtn addTarget:self action:@selector(selectDiskAction:) forControlEvents:UIControlEventTouchUpInside];
  153. [self.navBarBGView addSubview:tapBtn];
  154. [tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  156. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  157. make.width.mas_equalTo(100);
  158. make.height.mas_equalTo(30);
  159. }];
  160. [self setTitleLabelText:@""];
  161. rightTransferListButton = [[UIButton alloc] init];
  162. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  163. [rightTransferListButton addTarget:self action:@selector(didiClikRightButGotoTransferListFun:) forControlEvents:UIControlEventTouchUpInside];
  164. [self.navBarBGView addSubview:rightTransferListButton];
  165. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  166. make.width.mas_equalTo(40);
  167. make.height.mas_equalTo(40);
  168. make.right.mas_equalTo(-15);
  169. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  170. }];
  171. rightRedView = [[UIView alloc] init];
  172. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  173. [rightTransferListButton addSubview:rightRedView];
  174. rightRedView.layer.cornerRadius = 7;
  175. rightRedView.hidden = YES;
  176. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  177. make.width.mas_equalTo(14);
  178. make.height.mas_equalTo(14);
  179. make.right.mas_equalTo(0);
  180. make.top.mas_equalTo(6);
  181. }];
  182. }
  183. #pragma mark - 懒加载
  184. - (UITableView *)tableView{
  185. if (!_tableView) {
  186. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  187. _tableView.delegate = self;
  188. _tableView.dataSource = self;
  189. _tableView.showsVerticalScrollIndicator = NO;
  190. _tableView.showsHorizontalScrollIndicator = NO;
  191. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  192. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  193. [_tableView setSeparatorColor:[UIColor clearColor]];
  194. [_tableView setBackgroundColor:[UIColor clearColor]];
  195. [_tableView setTableFooterView:[UIView new]];
  196. [_tableView setBounces:YES];
  197. if (@available(iOS 15.0, *)) {
  198. _tableView.sectionHeaderTopPadding = 0;
  199. }
  200. //空数据引入第三方开源处理
  201. _tableView.emptyDataSetSource = self;
  202. _tableView.emptyDataSetDelegate = self;
  203. }
  204. return _tableView;
  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)numberOfSectionsInTableView:(UITableView *)tableView{
  261. return 1;
  262. }
  263. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  264. if(!_curCouldPhoneFileListMod){
  265. return 0;
  266. }
  267. return _curCouldPhoneFileListMod.data.list.count;
  268. }
  269. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  270. __block NSInteger row = indexPath.row;
  271. static NSString *identifier = @"downLoadPreViewCell";
  272. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  273. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  274. if (!cell){
  275. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  276. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  277. [cell setBackgroundColor:[UIColor clearColor]];
  278. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  279. [cell.bgViewLayer removeFromSuperlayer];
  280. [cell.titleLabel2 setHidden:NO];
  281. [cell.rightImage setHidden:YES];
  282. [cell.lineView setHidden:YES];
  283. [cell.checkButton setHidden:NO];
  284. }
  285. if(row < _curCouldPhoneFileListMod.data.list.count){
  286. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  287. cell.curFileModel = fileModel;
  288. KWeakSelf
  289. cell.didClickSwitch = ^(BOOL SwitchOn) {
  290. if([weakSelf userCheckFileModel:fileModel withShowTip:YES]){
  291. [weakSelf userCheckFilePreviewByRow:row];
  292. }
  293. };
  294. }
  295. return cell;
  296. }
  297. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  298. return 70;
  299. }
  300. #pragma mark 空数据
  301. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  302. NSString *imageName = @"uploadFile_noData";
  303. return [UIImage imageNamed:imageName];
  304. }
  305. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  306. NSString *text = NSLocalizedString(@"File_download_file_no_data",nil);
  307. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  308. NSForegroundColorAttributeName: HW999999Color};
  309. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  310. }
  311. //调整图片位置
  312. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  313. return -150;
  314. }
  315. //ios端:
  316. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  317. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  318. //ios支持图片格式: (SVG 不支持)
  319. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  320. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  321. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  322. NSString*name = [fileModel.name lowercaseString];
  323. NSArray *nameArr = [name componentsSeparatedByString:@"."];
  324. if(nameArr.count >0 && !_isAudioType){
  325. BOOL canDownLoadType = NO;
  326. NSString *lastName = nameArr.lastObject;
  327. if([lastName isEqualToString:@"mp4"]
  328. ||[lastName isEqualToString:@"mov"]
  329. ||[lastName isEqualToString:@"3gp"]
  330. ||[lastName isEqualToString:@"m4v"]){
  331. canDownLoadType = YES;
  332. }
  333. if(!canDownLoadType){
  334. if(canShow){
  335. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  336. }
  337. return NO;
  338. }
  339. }
  340. if(nameArr.count >0 && _isAudioType){
  341. BOOL canDownLoadType = NO;
  342. //JPG 、PNG、GIF、TIFF、BMP
  343. NSString *lastName = nameArr.lastObject;
  344. if([lastName isEqualToString:@"jpg"]
  345. ||[lastName isEqualToString:@"png"]
  346. ||[lastName isEqualToString:@"gif"]
  347. ||[lastName isEqualToString:@"tiff"]
  348. ||[lastName isEqualToString:@"bmp"]
  349. ||[lastName isEqualToString:@"heic"]
  350. ||[lastName isEqualToString:@"jpeg"]
  351. ||[lastName isEqualToString:@"heif"]){
  352. canDownLoadType = YES;
  353. }
  354. if(!canDownLoadType){
  355. if(canShow){
  356. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  357. }
  358. return NO;
  359. }
  360. }
  361. return YES;
  362. }
  363. #pragma mark 用户长按图片进入编辑
  364. - (void)setViewEditTypeFun
  365. {
  366. _isEditType = YES;
  367. [self.tableView reloadData];
  368. _curEditTypeHeadView.hidden = NO;
  369. _curEditTypeBottomView.hidden = NO;
  370. _uploadFileButton.hidden = YES;
  371. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  372. make.left.mas_equalTo(0);
  373. make.right.mas_equalTo(0);
  374. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  375. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  376. }];
  377. }
  378. #pragma mark 用户取消编辑编辑
  379. - (void)userCancelEditTypeFun
  380. {
  381. _isEditType = NO;
  382. [self.tableView reloadData];
  383. _curEditTypeHeadView.hidden = YES;
  384. _curEditTypeBottomView.hidden = YES;
  385. _uploadFileButton.hidden = NO;
  386. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  387. make.left.mas_equalTo(0);
  388. make.right.mas_equalTo(0);
  389. make.bottom.mas_equalTo(0);
  390. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  391. }];
  392. }
  393. - (void)userCheckFilePreviewByRow:(NSInteger)row
  394. {
  395. if(row < _curCouldPhoneFileListMod.data.list.count){
  396. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  397. if(fileModel.isSelectType){
  398. [_didSelectListArr removeObject:fileModel];
  399. }
  400. else{
  401. [_didSelectListArr addObject:fileModel];
  402. }
  403. fileModel.isSelectType = !fileModel.isSelectType;
  404. //[self.tableView reloadData];
  405. //[self.dataCollectionView reloadData];
  406. [self setEditTypeTitleFun];
  407. }
  408. }
  409. - (void)didClickSelectAllButton:(UIButton*)button
  410. {
  411. //button.selected = !button.selected;
  412. BOOL isNeedShowTip = NO;
  413. [_didSelectListArr removeAllObjects];
  414. for (couldPhoneFileModel* fileModel in _curCouldPhoneFileListMod.data.list) {
  415. if(!button.selected){
  416. fileModel.isSelectType = button.selected;
  417. }
  418. else{
  419. [_didSelectListArr addObject:fileModel];
  420. if([self userCheckFileModel:fileModel withShowTip:NO]){
  421. fileModel.isSelectType = button.selected;
  422. }
  423. else{
  424. isNeedShowTip = YES;
  425. }
  426. }
  427. }
  428. if(isNeedShowTip){
  429. if(_isAudioType){
  430. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  431. }
  432. else{
  433. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  434. }
  435. }
  436. [self.tableView reloadData];
  437. //[self.dataCollectionView reloadData];
  438. [self setEditTypeTitleFun];
  439. }
  440. #pragma mark 设置选中标题
  441. - (void)setEditTypeTitleFun
  442. {
  443. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  444. if(_didSelectListArr.count > 0){
  445. [self setViewEditTypeFun];
  446. }
  447. else{
  448. [self userCancelEditTypeFun];
  449. }
  450. }
  451. #pragma mark 用户点击分享
  452. - (void)gotoShareViewFun
  453. {
  454. editShareView *editShareV = [[editShareView alloc] init];
  455. [self.view addSubview:editShareV];
  456. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  457. make.left.mas_equalTo(0);
  458. make.right.mas_equalTo(0);
  459. make.bottom.mas_equalTo(0);
  460. make.top.mas_equalTo(0);
  461. }];
  462. }
  463. #pragma mark 用户点击上传文件
  464. - (void)userDidClickUploadViewFun
  465. {
  466. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  467. [self.view addSubview:previewToUploadFileV];
  468. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  469. make.left.mas_equalTo(0);
  470. make.right.mas_equalTo(0);
  471. make.bottom.mas_equalTo(0);
  472. make.top.mas_equalTo(0);
  473. }];
  474. }
  475. #pragma mark 设置标题
  476. - (void)setTitleLabelText:(NSString*)title
  477. {
  478. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  479. if(diskNameArr && diskNameArr.count >= 2){
  480. NSString *name = diskNameArr.lastObject;
  481. if(name.length == 0)
  482. {
  483. name = diskNameArr[diskNameArr.count -2];
  484. }
  485. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  486. }
  487. self.MytitleLabel.text = title;
  488. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  489. curWidth += 20;
  490. //HLog(@"title w:%f",curWidth);
  491. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  492. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  493. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  494. make.width.mas_equalTo(curWidth);
  495. make.height.mas_equalTo(30);
  496. }];
  497. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  498. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  499. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  500. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  501. make.width.mas_equalTo(15);
  502. make.height.mas_equalTo(15);
  503. }];
  504. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  505. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  506. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  507. make.width.mas_equalTo(curWidth+15);
  508. make.height.mas_equalTo(30);
  509. }];
  510. }
  511. #pragma mark 选择硬盘
  512. - (void)selectDiskAction:(UIButton*)but
  513. {
  514. if(self.diskListBgV.hidden){
  515. [self showDiskListVieFun];
  516. }
  517. else{
  518. [self hideDiskListVieFun];
  519. }
  520. }
  521. - (void)showDiskListVieFun
  522. {
  523. self.diskListBgV.hidden = NO;
  524. self.diskListTableV.hidden = NO;
  525. [UIView animateWithDuration:0.3 animations:^{
  526. CGRect rect = self.diskListTableV.frame;
  527. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  528. self.diskListTableV.frame = rect;
  529. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  530. }];
  531. }
  532. - (void)hideDiskListVieFun
  533. {
  534. self.diskListBgV.hidden = YES;
  535. [UIView animateWithDuration:0.3 animations:^{
  536. self.diskListTableV.hidden = YES;
  537. self.selectTip.transform = CGAffineTransformIdentity;
  538. }completion:^(BOOL finished) {
  539. CGRect rect = self.diskListTableV.frame;
  540. rect.origin.y = 0;
  541. self.diskListTableV.frame = rect;
  542. }];
  543. }
  544. #pragma mark 设置标题
  545. - (void)setTitleAfterGetdiskFun
  546. {
  547. if(_isAudioType){
  548. //self.titleLabel.text = NSLocalizedString(@"my_set_no_image_upload",nil) ;
  549. [self setTitleLabelText:NSLocalizedString(@"my_set_no_image_upload",nil)];
  550. }
  551. else{
  552. //self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
  553. [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
  554. }
  555. [self searchFileListFun];
  556. }
  557. - (void)viewWillAppear:(BOOL)animated
  558. {
  559. [super viewWillAppear:animated];
  560. }
  561. - (void)viewDidAppear:(BOOL)animated{
  562. [super viewDidAppear:animated];
  563. [self showDownloadTipFun];
  564. [self checkFileTransferTask];
  565. }
  566. - (void)viewWillDisappear:(BOOL)animated{
  567. [super viewWillDisappear:animated];
  568. //[self removeNewIndicator];
  569. [self removeNewIndicatorHaveStr];
  570. }
  571. - (void)searchFileListFun
  572. {
  573. NSMutableDictionary *dict = [NSMutableDictionary new];
  574. NSNumber *curNum = [NSNumber numberWithBool:_isAudioType];
  575. [dict setObject:curNum forKey:@"type"];
  576. if(!_defaultDiskPath){
  577. _defaultDiskPath = @"";
  578. }
  579. [dict setObject:_defaultDiskPath forKey:@"path"];
  580. [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListBeginNotification object:dict];/*发送通知*/
  581. //[self showNewIndicatorWithCanBack:YES canTouch:NO];
  582. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  583. }
  584. - (void)searchFileListDoneFun:(NSNotification*)notification
  585. {
  586. //[self removeNewIndicator];
  587. [self removeNewIndicatorHaveStr];
  588. NSDictionary *dataDict = [notification object];
  589. if(!dataDict || ![dataDict isKindOfClass:[NSDictionary class]]){
  590. return;
  591. }
  592. _curCouldPhoneFileListMod = [[couldPhoneFileListModel alloc] initWithDictionary:dataDict error:nil];
  593. NSMutableArray *filterArr = [NSMutableArray new];
  594. for (couldPhoneFileModel*model in _curCouldPhoneFileListMod.data.list) {
  595. //if(model.length > 1024)
  596. if(model.length > 1024*50)
  597. {
  598. [filterArr addObject:model];
  599. }
  600. }
  601. _curCouldPhoneFileListMod.data.list = filterArr;
  602. [self.tableView reloadData];
  603. //[self.dataCollectionView reloadData];
  604. //这个要做判断 不能为空
  605. [self gotoDownThumbnailManagerFun];
  606. }
  607. #pragma mark 去下载缩略图
  608. - (void)gotoDownThumbnailManagerFun
  609. {
  610. // if(_curCouldPhoneFileListMod.data.list && _curCouldPhoneFileListMod.data.list.count >0){
  611. // [[downloadThumbnailManager shareInstance] handlToDownloadThumbnailWith:_curCouldPhoneFileListMod.data.list];
  612. // }
  613. }
  614. - (void)gotoDownloadloadFileRecordFun
  615. {
  616. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  617. [self.navigationController pushViewController:vc animated:YES];
  618. vc.isDownloadingType = YES;
  619. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  620. }
  621. - (void)showDownloadTipFun
  622. {
  623. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  624. if(didReadUploadTipType){
  625. return;
  626. }
  627. //KWeakSelf
  628. /*弹窗提示恢复出厂*/
  629. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  630. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  631. imageStr:nil
  632. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  633. okTitle:nil
  634. isOkBtnHighlight:NO
  635. didClickOk:^{
  636. } didClickCancel:^{
  637. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  638. }];
  639. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  640. [self presentViewController:nextVC animated:YES completion:^{
  641. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  642. }];
  643. }
  644. - (void)didDownloadOneFileFun
  645. {
  646. mainBlock(^{
  647. [self.tableView reloadData];
  648. //[self.dataCollectionView reloadData];
  649. });
  650. }
  651. - (void)checkFileTransferTask
  652. {//有个偶现的闪退在BGFMDB
  653. [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  654. self->hadUploadTaskType = isSuccess;
  655. [self setRightButtonRedTypeFun];
  656. }];
  657. KWeakSelf
  658. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  659. [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  660. self->hadDownloadTaskType = isSuccess;
  661. [weakSelf setRightButtonRedTypeFun];
  662. }];
  663. });
  664. }
  665. - (void)setRightButtonRedTypeFun
  666. {
  667. mainBlock(^{
  668. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  669. self->rightRedView.hidden = NO;
  670. }
  671. else{
  672. self->rightRedView.hidden = YES;
  673. }
  674. });
  675. }
  676. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  677. {
  678. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  679. [self.navigationController pushViewController:vc animated:YES];
  680. }
  681. @end