previewAudioOrDocumentViewController.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  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. KWeakSelf
  473. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  474. [weakSelf gotoUploadFileFunWith:tag];
  475. };
  476. }
  477. #pragma mark 设置标题
  478. - (void)setTitleLabelText:(NSString*)title
  479. {
  480. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  481. if(diskNameArr && diskNameArr.count >= 2){
  482. NSString *name = diskNameArr.lastObject;
  483. if(name.length == 0)
  484. {
  485. name = diskNameArr[diskNameArr.count -2];
  486. }
  487. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  488. }
  489. self.MytitleLabel.text = title;
  490. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  491. curWidth += 20;
  492. //HLog(@"title w:%f",curWidth);
  493. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  494. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  495. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  496. make.width.mas_equalTo(curWidth);
  497. make.height.mas_equalTo(30);
  498. }];
  499. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  500. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  501. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  502. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  503. make.width.mas_equalTo(15);
  504. make.height.mas_equalTo(15);
  505. }];
  506. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  507. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  508. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  509. make.width.mas_equalTo(curWidth+15);
  510. make.height.mas_equalTo(30);
  511. }];
  512. }
  513. #pragma mark 选择硬盘
  514. - (void)selectDiskAction:(UIButton*)but
  515. {
  516. if(self.diskListBgV.hidden){
  517. [self showDiskListVieFun];
  518. }
  519. else{
  520. [self hideDiskListVieFun];
  521. }
  522. }
  523. - (void)showDiskListVieFun
  524. {
  525. self.diskListBgV.hidden = NO;
  526. self.diskListTableV.hidden = NO;
  527. [UIView animateWithDuration:0.3 animations:^{
  528. CGRect rect = self.diskListTableV.frame;
  529. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  530. self.diskListTableV.frame = rect;
  531. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  532. }];
  533. }
  534. - (void)hideDiskListVieFun
  535. {
  536. self.diskListBgV.hidden = YES;
  537. [UIView animateWithDuration:0.3 animations:^{
  538. self.diskListTableV.hidden = YES;
  539. self.selectTip.transform = CGAffineTransformIdentity;
  540. }completion:^(BOOL finished) {
  541. CGRect rect = self.diskListTableV.frame;
  542. rect.origin.y = 0;
  543. self.diskListTableV.frame = rect;
  544. }];
  545. }
  546. #pragma mark 设置标题
  547. - (void)setTitleAfterGetdiskFun
  548. {
  549. if(_isAudioType){
  550. //self.titleLabel.text = NSLocalizedString(@"my_set_no_image_upload",nil) ;
  551. [self setTitleLabelText:NSLocalizedString(@"my_set_no_image_upload",nil)];
  552. }
  553. else{
  554. //self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
  555. [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
  556. }
  557. }
  558. - (void)viewWillAppear:(BOOL)animated
  559. {
  560. [super viewWillAppear:animated];
  561. }
  562. - (void)viewDidAppear:(BOOL)animated{
  563. [super viewDidAppear:animated];
  564. [self showDownloadTipFun];
  565. [self checkFileTransferTask];
  566. [self getFileListFun];
  567. }
  568. - (void)viewWillDisappear:(BOOL)animated{
  569. [super viewWillDisappear:animated];
  570. //[self removeNewIndicator];
  571. [self removeNewIndicatorHaveStr];
  572. }
  573. - (void)gotoDownloadloadFileRecordFun
  574. {
  575. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  576. [self.navigationController pushViewController:vc animated:YES];
  577. vc.isDownloadingType = YES;
  578. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  579. }
  580. - (void)showDownloadTipFun
  581. {
  582. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  583. if(didReadUploadTipType){
  584. return;
  585. }
  586. //KWeakSelf
  587. /*弹窗提示恢复出厂*/
  588. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  589. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  590. imageStr:nil
  591. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  592. okTitle:nil
  593. isOkBtnHighlight:NO
  594. didClickOk:^{
  595. } didClickCancel:^{
  596. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  597. }];
  598. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  599. [self presentViewController:nextVC animated:YES completion:^{
  600. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  601. }];
  602. }
  603. - (void)checkFileTransferTask
  604. {//有个偶现的闪退在BGFMDB
  605. [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  606. self->hadUploadTaskType = isSuccess;
  607. [self setRightButtonRedTypeFun];
  608. }];
  609. KWeakSelf
  610. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  611. [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  612. self->hadDownloadTaskType = isSuccess;
  613. [weakSelf setRightButtonRedTypeFun];
  614. }];
  615. });
  616. }
  617. - (void)setRightButtonRedTypeFun
  618. {
  619. mainBlock(^{
  620. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  621. self->rightRedView.hidden = NO;
  622. }
  623. else{
  624. self->rightRedView.hidden = YES;
  625. }
  626. });
  627. }
  628. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  629. {
  630. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  631. [self.navigationController pushViewController:vc animated:YES];
  632. }
  633. #pragma mark 获取文件数据
  634. - (void)getFileListFun
  635. {
  636. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  637. if(_isAudioType){
  638. [paraDict setValue:@"audio" forKey:@"type"];
  639. }
  640. else{
  641. [paraDict setValue:@"file" forKey:@"type"];
  642. }
  643. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  644. KWeakSelf
  645. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileList" Parameters:paraDict success:^(id _Nonnull responseObject) {
  646. [weakSelf removeNewIndicatorHaveStr];
  647. } failure:^(NSError * _Nonnull error) {
  648. [weakSelf removeNewIndicatorHaveStr];
  649. }];
  650. }
  651. #pragma mark 调整文件上传
  652. - (void)gotoUploadFileFunWith:(NSInteger)tag
  653. {
  654. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  655. if(tag ==10){
  656. vc.isPhotoType = YES;
  657. }
  658. else{
  659. vc.isPhotoType = NO;
  660. }
  661. [self.navigationController pushViewController:vc animated:YES];
  662. }
  663. @end