previewAudioOrDocumentViewController.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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. #import "netWorkManager.h"
  21. @interface previewAudioOrDocumentViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  22. {
  23. UIButton *tapBtn;
  24. UIButton* rightTransferListButton;//传输列表
  25. UIView* rightRedView;
  26. BOOL hadUploadTaskType;
  27. BOOL hadDownloadTaskType;
  28. }
  29. @property (nonatomic, strong) UITableView *tableView;
  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 previewAudioOrDocumentViewController
  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.tableView];
  98. [self.tableView 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. - (UITableView *)tableView{
  184. if (!_tableView) {
  185. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  186. _tableView.delegate = self;
  187. _tableView.dataSource = self;
  188. _tableView.showsVerticalScrollIndicator = NO;
  189. _tableView.showsHorizontalScrollIndicator = NO;
  190. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  191. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  192. [_tableView setSeparatorColor:[UIColor clearColor]];
  193. [_tableView setBackgroundColor:[UIColor clearColor]];
  194. [_tableView setTableFooterView:[UIView new]];
  195. [_tableView setBounces:YES];
  196. if (@available(iOS 15.0, *)) {
  197. _tableView.sectionHeaderTopPadding = 0;
  198. }
  199. //空数据引入第三方开源处理
  200. _tableView.emptyDataSetSource = self;
  201. _tableView.emptyDataSetDelegate = self;
  202. }
  203. return _tableView;
  204. }
  205. - (diskListBgView*)diskListBgV
  206. {
  207. if(!_diskListBgV){
  208. _diskListBgV = [[diskListBgView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
  209. _diskListBgV.hidden = YES;
  210. [self.view addSubview:_diskListBgV];
  211. KWeakSelf
  212. _diskListBgV.didTapWhitePlace = ^{
  213. [weakSelf hideDiskListVieFun];
  214. };
  215. [_diskListBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  216. make.left.mas_equalTo(0);
  217. make.bottom.mas_equalTo(0);
  218. make.right.mas_equalTo(0);
  219. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  220. }];
  221. [self.view addSubview:self.diskListTableV];
  222. self.diskListTableV.hidden = YES;
  223. [self.diskListTableV mas_makeConstraints:^(MASConstraintMaker *make) {
  224. make.left.mas_equalTo(0);
  225. make.height.mas_equalTo(3*70);
  226. make.right.mas_equalTo(0);
  227. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  228. }];
  229. self.diskListTableV.diskListArr = _diskListArr;
  230. self.diskListTableV.didClickDiskModel = ^(NSString * _Nonnull checkPath) {
  231. [weakSelf didCheckDiskFunByPath:checkPath];
  232. };
  233. }
  234. return _diskListBgV;
  235. }
  236. - (UITableView *)diskListTableV{
  237. if (!_diskListTableV) {
  238. _diskListTableV = [[diskListTableView alloc] init];
  239. //
  240. }
  241. return _diskListTableV;
  242. }
  243. #pragma mark 选中磁盘
  244. - (void)didCheckDiskFunByPath:(NSString*)pathStr
  245. {
  246. if(self.defaultDiskPath
  247. && self.defaultDiskPath.length>0
  248. && ![self.defaultDiskPath isEqualToString:pathStr]){
  249. //切换硬盘了 取消全选
  250. //_rightSelectAllButton.selected = YES;
  251. //[self didClickSelectAllButton:_rightSelectAllButton];
  252. }
  253. self.defaultDiskPath = pathStr;
  254. [self setTitleAfterGetdiskFun];
  255. [self hideDiskListVieFun];
  256. }
  257. #pragma mark - 列表委托
  258. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  259. return 1;
  260. }
  261. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  262. if(!_curCouldPhoneFileListMod){
  263. return 0;
  264. }
  265. return _curCouldPhoneFileListMod.data.list.count;
  266. }
  267. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  268. __block NSInteger row = indexPath.row;
  269. static NSString *identifier = @"downLoadPreViewCell";
  270. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  271. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  272. if (!cell){
  273. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  274. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  275. [cell setBackgroundColor:[UIColor clearColor]];
  276. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  277. [cell.bgViewLayer removeFromSuperlayer];
  278. [cell.titleLabel2 setHidden:NO];
  279. [cell.rightImage setHidden:YES];
  280. [cell.lineView setHidden:YES];
  281. [cell.checkButton setHidden:NO];
  282. }
  283. if(row < _curCouldPhoneFileListMod.data.list.count){
  284. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  285. cell.curFileModel = fileModel;
  286. KWeakSelf
  287. cell.didClickSwitch = ^(BOOL SwitchOn) {
  288. if([weakSelf userCheckFileModel:fileModel withShowTip:YES]){
  289. [weakSelf userCheckFilePreviewByRow:row];
  290. }
  291. };
  292. }
  293. return cell;
  294. }
  295. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  296. return 70;
  297. }
  298. #pragma mark 空数据
  299. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  300. NSString *imageName = @"uploadFile_noData";
  301. return [UIImage imageNamed:imageName];
  302. }
  303. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  304. NSString *text = NSLocalizedString(@"File_download_file_no_data",nil);
  305. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  306. NSForegroundColorAttributeName: HW999999Color};
  307. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  308. }
  309. //调整图片位置
  310. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  311. return -150;
  312. }
  313. //ios端:
  314. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  315. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  316. //ios支持图片格式: (SVG 不支持)
  317. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  318. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  319. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  320. NSString*name = [fileModel.name lowercaseString];
  321. NSArray *nameArr = [name componentsSeparatedByString:@"."];
  322. if(nameArr.count >0 && !_isAudioType){
  323. BOOL canDownLoadType = NO;
  324. NSString *lastName = nameArr.lastObject;
  325. if([lastName isEqualToString:@"mp4"]
  326. ||[lastName isEqualToString:@"mov"]
  327. ||[lastName isEqualToString:@"3gp"]
  328. ||[lastName isEqualToString:@"m4v"]){
  329. canDownLoadType = YES;
  330. }
  331. if(!canDownLoadType){
  332. if(canShow){
  333. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  334. }
  335. return NO;
  336. }
  337. }
  338. if(nameArr.count >0 && _isAudioType){
  339. BOOL canDownLoadType = NO;
  340. //JPG 、PNG、GIF、TIFF、BMP
  341. NSString *lastName = nameArr.lastObject;
  342. if([lastName isEqualToString:@"jpg"]
  343. ||[lastName isEqualToString:@"png"]
  344. ||[lastName isEqualToString:@"gif"]
  345. ||[lastName isEqualToString:@"tiff"]
  346. ||[lastName isEqualToString:@"bmp"]
  347. ||[lastName isEqualToString:@"heic"]
  348. ||[lastName isEqualToString:@"jpeg"]
  349. ||[lastName isEqualToString:@"heif"]){
  350. canDownLoadType = YES;
  351. }
  352. if(!canDownLoadType){
  353. if(canShow){
  354. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  355. }
  356. return NO;
  357. }
  358. }
  359. return YES;
  360. }
  361. #pragma mark 用户长按图片进入编辑
  362. - (void)setViewEditTypeFun
  363. {
  364. _isEditType = YES;
  365. [self.tableView reloadData];
  366. _curEditTypeHeadView.hidden = NO;
  367. _curEditTypeBottomView.hidden = NO;
  368. _uploadFileButton.hidden = YES;
  369. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  370. make.left.mas_equalTo(0);
  371. make.right.mas_equalTo(0);
  372. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  373. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  374. }];
  375. }
  376. #pragma mark 用户取消编辑编辑
  377. - (void)userCancelEditTypeFun
  378. {
  379. _isEditType = NO;
  380. [self.tableView reloadData];
  381. _curEditTypeHeadView.hidden = YES;
  382. _curEditTypeBottomView.hidden = YES;
  383. _uploadFileButton.hidden = NO;
  384. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  385. make.left.mas_equalTo(0);
  386. make.right.mas_equalTo(0);
  387. make.bottom.mas_equalTo(0);
  388. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  389. }];
  390. }
  391. - (void)userCheckFilePreviewByRow:(NSInteger)row
  392. {
  393. if(row < _curCouldPhoneFileListMod.data.list.count){
  394. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  395. if(fileModel.isSelectType){
  396. [_didSelectListArr removeObject:fileModel];
  397. }
  398. else{
  399. [_didSelectListArr addObject:fileModel];
  400. }
  401. fileModel.isSelectType = !fileModel.isSelectType;
  402. //[self.tableView reloadData];
  403. //[self.dataCollectionView reloadData];
  404. [self setEditTypeTitleFun];
  405. }
  406. }
  407. - (void)didClickSelectAllButton:(UIButton*)button
  408. {
  409. //button.selected = !button.selected;
  410. BOOL isNeedShowTip = NO;
  411. [_didSelectListArr removeAllObjects];
  412. for (couldPhoneFileModel* fileModel in _curCouldPhoneFileListMod.data.list) {
  413. if(!button.selected){
  414. fileModel.isSelectType = button.selected;
  415. }
  416. else{
  417. [_didSelectListArr addObject:fileModel];
  418. if([self userCheckFileModel:fileModel withShowTip:NO]){
  419. fileModel.isSelectType = button.selected;
  420. }
  421. else{
  422. isNeedShowTip = YES;
  423. }
  424. }
  425. }
  426. if(isNeedShowTip){
  427. if(_isAudioType){
  428. [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  429. }
  430. else{
  431. [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  432. }
  433. }
  434. [self.tableView reloadData];
  435. //[self.dataCollectionView reloadData];
  436. [self setEditTypeTitleFun];
  437. }
  438. #pragma mark 设置选中标题
  439. - (void)setEditTypeTitleFun
  440. {
  441. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  442. if(_didSelectListArr.count > 0){
  443. [self setViewEditTypeFun];
  444. }
  445. else{
  446. [self userCancelEditTypeFun];
  447. }
  448. }
  449. #pragma mark 用户点击分享
  450. - (void)gotoShareViewFun
  451. {
  452. editShareView *editShareV = [[editShareView alloc] init];
  453. [self.view addSubview:editShareV];
  454. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  455. make.left.mas_equalTo(0);
  456. make.right.mas_equalTo(0);
  457. make.bottom.mas_equalTo(0);
  458. make.top.mas_equalTo(0);
  459. }];
  460. }
  461. #pragma mark 用户点击上传文件
  462. - (void)userDidClickUploadViewFun
  463. {
  464. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  465. [self.view addSubview:previewToUploadFileV];
  466. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  467. make.left.mas_equalTo(0);
  468. make.right.mas_equalTo(0);
  469. make.bottom.mas_equalTo(0);
  470. make.top.mas_equalTo(0);
  471. }];
  472. }
  473. #pragma mark 设置标题
  474. - (void)setTitleLabelText:(NSString*)title
  475. {
  476. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  477. if(diskNameArr && diskNameArr.count >= 2){
  478. NSString *name = diskNameArr.lastObject;
  479. if(name.length == 0)
  480. {
  481. name = diskNameArr[diskNameArr.count -2];
  482. }
  483. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  484. }
  485. self.MytitleLabel.text = title;
  486. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  487. curWidth += 20;
  488. //HLog(@"title w:%f",curWidth);
  489. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  490. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  491. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  492. make.width.mas_equalTo(curWidth);
  493. make.height.mas_equalTo(30);
  494. }];
  495. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  496. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  497. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  498. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  499. make.width.mas_equalTo(15);
  500. make.height.mas_equalTo(15);
  501. }];
  502. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  503. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  504. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  505. make.width.mas_equalTo(curWidth+15);
  506. make.height.mas_equalTo(30);
  507. }];
  508. }
  509. #pragma mark 选择硬盘
  510. - (void)selectDiskAction:(UIButton*)but
  511. {
  512. if(self.diskListBgV.hidden){
  513. [self showDiskListVieFun];
  514. }
  515. else{
  516. [self hideDiskListVieFun];
  517. }
  518. }
  519. - (void)showDiskListVieFun
  520. {
  521. self.diskListBgV.hidden = NO;
  522. self.diskListTableV.hidden = NO;
  523. [UIView animateWithDuration:0.3 animations:^{
  524. CGRect rect = self.diskListTableV.frame;
  525. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  526. self.diskListTableV.frame = rect;
  527. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  528. }];
  529. }
  530. - (void)hideDiskListVieFun
  531. {
  532. self.diskListBgV.hidden = YES;
  533. [UIView animateWithDuration:0.3 animations:^{
  534. self.diskListTableV.hidden = YES;
  535. self.selectTip.transform = CGAffineTransformIdentity;
  536. }completion:^(BOOL finished) {
  537. CGRect rect = self.diskListTableV.frame;
  538. rect.origin.y = 0;
  539. self.diskListTableV.frame = rect;
  540. }];
  541. }
  542. #pragma mark 设置标题
  543. - (void)setTitleAfterGetdiskFun
  544. {
  545. if(_isAudioType){
  546. //self.titleLabel.text = NSLocalizedString(@"my_set_no_image_upload",nil) ;
  547. [self setTitleLabelText:NSLocalizedString(@"my_set_no_image_upload",nil)];
  548. }
  549. else{
  550. //self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
  551. [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
  552. }
  553. }
  554. - (void)viewWillAppear:(BOOL)animated
  555. {
  556. [super viewWillAppear:animated];
  557. }
  558. - (void)viewDidAppear:(BOOL)animated{
  559. [super viewDidAppear:animated];
  560. [self showDownloadTipFun];
  561. [self checkFileTransferTask];
  562. [self getFileListFun];
  563. }
  564. - (void)viewWillDisappear:(BOOL)animated{
  565. [super viewWillDisappear:animated];
  566. //[self removeNewIndicator];
  567. [self removeNewIndicatorHaveStr];
  568. }
  569. - (void)gotoDownloadloadFileRecordFun
  570. {
  571. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  572. [self.navigationController pushViewController:vc animated:YES];
  573. vc.isDownloadingType = YES;
  574. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  575. }
  576. - (void)showDownloadTipFun
  577. {
  578. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  579. if(didReadUploadTipType){
  580. return;
  581. }
  582. //KWeakSelf
  583. /*弹窗提示恢复出厂*/
  584. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  585. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  586. imageStr:nil
  587. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  588. okTitle:nil
  589. isOkBtnHighlight:NO
  590. didClickOk:^{
  591. } didClickCancel:^{
  592. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  593. }];
  594. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  595. [self presentViewController:nextVC animated:YES completion:^{
  596. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  597. }];
  598. }
  599. - (void)checkFileTransferTask
  600. {//有个偶现的闪退在BGFMDB
  601. [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  602. self->hadUploadTaskType = isSuccess;
  603. [self setRightButtonRedTypeFun];
  604. }];
  605. KWeakSelf
  606. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  607. [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  608. self->hadDownloadTaskType = isSuccess;
  609. [weakSelf setRightButtonRedTypeFun];
  610. }];
  611. });
  612. }
  613. - (void)setRightButtonRedTypeFun
  614. {
  615. mainBlock(^{
  616. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  617. self->rightRedView.hidden = NO;
  618. }
  619. else{
  620. self->rightRedView.hidden = YES;
  621. }
  622. });
  623. }
  624. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  625. {
  626. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  627. [self.navigationController pushViewController:vc animated:YES];
  628. }
  629. #pragma mark 获取文件数据
  630. - (void)getFileListFun
  631. {
  632. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  633. if(_isAudioType){
  634. [paraDict setValue:@"audio" forKey:@"type"];
  635. }
  636. else{
  637. [paraDict setValue:@"file" forKey:@"type"];
  638. }
  639. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  640. KWeakSelf
  641. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileList" Parameters:paraDict success:^(id _Nonnull responseObject) {
  642. [weakSelf removeNewIndicatorHaveStr];
  643. } failure:^(NSError * _Nonnull error) {
  644. [weakSelf removeNewIndicatorHaveStr];
  645. }];
  646. }
  647. @end