1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153 |
- //
- // previewAudioOrDocumentViewController.m
- // Private-X
- //
- // Created by xd h on 2024/5/14.
- //
- #import "previewAudioOrDocumentViewController.h"
- #import "couldPhoneFileListModel.h"
- #import "downloadManager.h"
- #import "uploadFileRecordViewController.h"
- #import "UIScrollView+EmptyDataSet.h"
- #import "diskListBgView.h"
- #import "diskListTableView.h"
- #import "downLoadPreViewCell.h"
- #import "editTypeHeadView.h"
- #import "editTypeBottomView.h"
- #import "editShareView.h"
- #import "previewToUploadFileView.h"
- #import "netWorkManager.h"
- #import "NASFileAudioModel.h"
- #import "queryShareModel.h"
- #import "audioPlayerViewController.h"
- #import "videoPlayByAVPlayerViewController.h"
- #import "MJRefresh.h"
- #import "DocumentPickerManager.h"
- @interface previewAudioOrDocumentViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
- {
- UIButton *tapBtn;
-
- UIButton* rightTransferListButton;//传输列表
- UIView* rightRedView;
-
- BOOL hadUploadTaskType;
- BOOL hadDownloadTaskType;
- BOOL canShareType;
- }
- @property (nonatomic, strong) UITableView *tableView;
- @property (strong, nonatomic) UILabel *MytitleLabel;
- @property (strong, nonatomic) UIImageView *selectTip;
- @property (nonatomic, strong) diskListBgView *diskListBgV;
- @property (nonatomic, strong) diskListTableView *diskListTableV;
- @property (nonatomic, strong) NSMutableArray*diskListArr;
- @property (nonatomic, copy) NSString *defaultDiskPath;
- @property(nonatomic,assign) BOOL isEditType;
- @property(nonatomic,strong) editTypeHeadView*curEditTypeHeadView;
- @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
- @property(nonatomic,strong) UIButton*uploadFileButton;
- @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
- @property (nonatomic, strong)NASFileAudioModel * curNASFileAudioMod;
- @end
- @implementation previewAudioOrDocumentViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:NO];
- self.navBarBGView.backgroundColor = [UIColor whiteColor];
- [self.view setBackgroundColor:[UIColor whiteColor]];
-
- [self drawAnyView];
-
- _didSelectListArr = [NSMutableArray new];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Music"];
- }
- - (void)drawAnyView{
-
- [self initNavHeadUIFun];
-
- _curEditTypeHeadView = [[editTypeHeadView alloc] init];
- _curEditTypeHeadView.hidden = YES;
- [self.navBarBGView addSubview:_curEditTypeHeadView];
-
- [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
- }];
-
- #pragma mark 编辑状态的 取消 和全选按钮 响应事件
- KWeakSelf
- _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
- if(tag==1){
- [weakSelf userCancelEditTypeFun];
- }
- };
-
- _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
- [weakSelf didClickSelectAllButton:but];
- };
-
-
- _curEditTypeBottomView = [[editTypeBottomView alloc] init];
- _curEditTypeBottomView.hidden = YES;
- [self.view addSubview:_curEditTypeBottomView];
-
- [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.height.mas_equalTo(60 + AdaptTabHeight);
- }];
-
- #pragma mark 编辑状态的 下载 分享 删除 响应事件
- _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
- if(tag==1){
- [weakSelf gotoDownLoadFileFun];
- }
- else if(tag==2){
- [weakSelf gotoShareViewFun];
- }
- else if(tag==3){
- [weakSelf showDeleteAlearViewFun];
- }
- };
-
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- //make.bottom.mas_equalTo(-(safeArea));
- make.bottom.mas_equalTo(0);
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
- }];
-
- //大+号
- _uploadFileButton = [[UIButton alloc] init];
- [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
- [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:_uploadFileButton];
- [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-15);
- make.width.mas_equalTo(52);
- make.height.mas_equalTo(52);
- make.bottom.mas_equalTo(-30 - AdaptTabHeight);
- }];
-
- NSMutableArray *arr = [NSMutableArray new];
- NSArray *diskList = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
- if(diskList && [diskList isKindOfClass:[NSArray class]]){
- for (cloudPhoneExtraFileModel *model in diskList) {
- model.isCheckType = NO;
- [arr addObject:model];
- }
- }
-
- if(arr.count >0){
- //上一次选中的磁盘
- NSString*preChekDiskStr = [HWDataManager getStringWithKey:Const_audio_pre_disk_check];
-
- //1.没有选择过 默认选择第一次(云机)
- if(!preChekDiskStr || preChekDiskStr.length == 0){
- cloudPhoneExtraFileModel *model = arr.firstObject;
- model.isCheckType = YES;
- _defaultDiskPath = model.extraPath;
- }
- else{//2.选择过 查询磁盘是否还存在
- BOOL didCheckDisk = NO;
- for (cloudPhoneExtraFileModel *model in arr) {
- HLog(@"磁盘路径比较 pre:%@---%@",preChekDiskStr,model.extraPath)
- if([model.extraPath isEqualToString:preChekDiskStr]){
- model.isCheckType = YES;
- _defaultDiskPath = model.extraPath;
- didCheckDisk = YES;
- break;
- }
- }
-
- //3.选择过 查询磁盘不存在
- if(!didCheckDisk){
- cloudPhoneExtraFileModel *model = arr.firstObject;
- model.isCheckType = YES;
- _defaultDiskPath = model.extraPath;
- }
- }
- }
- _diskListArr = arr;
- [self setTitleAfterGetdiskFun];
- }
- - (void)initNavHeadUIFun
- {
- //title
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.textAlignment = NSTextAlignmentCenter;
- titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
- titleLabel.textColor = [UIColor blackColor];
- titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
- [self.navBarBGView addSubview:titleLabel];
- self.MytitleLabel = titleLabel;
-
- //selectTipImageView
- UIImageView *selectTip = [[UIImageView alloc] init];
- selectTip.image = [UIImage imageNamed:@"upload_image_arrow"];
- selectTip.translatesAutoresizingMaskIntoConstraints = NO;
- [self.navBarBGView addSubview:selectTip];
- self.selectTip = selectTip;
-
- tapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- tapBtn.backgroundColor = [UIColor clearColor];
- tapBtn.translatesAutoresizingMaskIntoConstraints = NO;
- [tapBtn addTarget:self action:@selector(selectDiskAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.navBarBGView addSubview:tapBtn];
-
- [tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
- make.centerY.mas_equalTo(self.backBtn.mas_centerY);
- make.width.mas_equalTo(100);
- make.height.mas_equalTo(30);
- }];
-
- [self setTitleLabelText:@""];
-
- rightTransferListButton = [[UIButton alloc] init];
- [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
- [rightTransferListButton addTarget:self action:@selector(didiClikRightButGotoTransferListFun:) forControlEvents:UIControlEventTouchUpInside];
- [self.navBarBGView addSubview:rightTransferListButton];
-
- [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(40);
- make.height.mas_equalTo(40);
- make.right.mas_equalTo(-15);
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- }];
-
- rightRedView = [[UIView alloc] init];
- rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
- [rightTransferListButton addSubview:rightRedView];
- rightRedView.layer.cornerRadius = 7;
- rightRedView.hidden = YES;
-
- [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(14);
- make.height.mas_equalTo(14);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(6);
- }];
-
- }
- #pragma mark - 懒加载
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
- [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
- [_tableView setSeparatorColor:[UIColor clearColor]];
- [_tableView setBackgroundColor:[UIColor clearColor]];
- [_tableView setTableFooterView:[UIView new]];
- [_tableView setBounces:YES];
-
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
-
- //空数据引入第三方开源处理
- _tableView.emptyDataSetSource = self;
- _tableView.emptyDataSetDelegate = self;
-
- // 下拉追加
- // MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
- // [self getMoreNetWorkData];
- // }];
- //
- // NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
- // [footer setTitle:text forState:MJRefreshStateNoMoreData];
- // _tableView.mj_footer = footer;
- }
-
- return _tableView;
- }
- - (diskListBgView*)diskListBgV
- {
- if(!_diskListBgV){
- _diskListBgV = [[diskListBgView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
- _diskListBgV.hidden = YES;
- [self.view addSubview:_diskListBgV];
-
- KWeakSelf
- _diskListBgV.didTapWhitePlace = ^{
- [weakSelf hideDiskListVieFun];
- };
-
- [_diskListBgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(self.navBarBGView.mas_bottom);
- }];
-
- [self.view addSubview:self.diskListTableV];
- self.diskListTableV.hidden = YES;
- [self.diskListTableV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.height.mas_equalTo(3*70);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(self.navBarBGView.mas_bottom);
- }];
-
- self.diskListTableV.diskListArr = _diskListArr;
-
- self.diskListTableV.didClickDiskModel = ^(NSString * _Nonnull checkPath) {
- [weakSelf didCheckDiskFunByPath:checkPath];
- };
- }
-
- return _diskListBgV;
- }
- - (UITableView *)diskListTableV{
- if (!_diskListTableV) {
- _diskListTableV = [[diskListTableView alloc] init];
- //
- }
- return _diskListTableV;
- }
- #pragma mark 选中磁盘
- - (void)didCheckDiskFunByPath:(NSString*)pathStr
- {
- if(self.defaultDiskPath
- && self.defaultDiskPath.length>0
- && ![self.defaultDiskPath isEqualToString:pathStr]){
- //切换硬盘了 取消全选
-
- [_didSelectListArr removeAllObjects];
- }
-
- //保存选中的磁盘
- if(pathStr){
- [HWDataManager setStringWithKey:Const_audio_pre_disk_check value:pathStr];
- }
-
- self.defaultDiskPath = pathStr;
- _curNASFileAudioMod = nil;
- [self getFileListFun:NO];
- [self setTitleAfterGetdiskFun];
- [self hideDiskListVieFun];
- }
- #pragma mark - 列表委托
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if(!_curNASFileAudioMod){
- return 0;
- }
- return _curNASFileAudioMod.data.list.count;
- }
- - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- __block NSInteger row = indexPath.row;
- static NSString *identifier = @"downLoadPreViewCell";
-
- downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (!cell){
- cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- [cell setBackgroundColor:[UIColor clearColor]];
- [cell setAccessoryType:(UITableViewCellAccessoryNone)];
-
- [cell.bgViewLayer removeFromSuperlayer];
- [cell.titleLabel2 setHidden:NO];
- [cell.rightImage setHidden:YES];
- [cell.lineView setHidden:YES];
- [cell.checkButton setHidden:NO];
-
- }
-
- if(row < _curNASFileAudioMod.data.list.count){
- NASFileAudioDataModel* dataModel = _curNASFileAudioMod.data.list[row];
- cell.curNASFileAudioDataModel = dataModel;
-
- KWeakSelf
- cell.didClickSwitch = ^(BOOL SwitchOn) {
- //if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
- [weakSelf userCheckFilePreviewByRow:row];
- //}
- };
- }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 70;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSInteger row = indexPath.row;
- if(row < _curNASFileAudioMod.data.list.count){
-
- // NASFileAudioDataModel*dataModel = _curNASFileAudioMod.data.list[row];
- // videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
- // NASFilePicDataArrModel *VideoDataMode = [NASFilePicDataArrModel new];
- // VideoDataMode.size = dataModel.size;
- // VideoDataMode.path = dataModel.path;
- // VideoDataMode.name = dataModel.name;
- // VideoDataMode.time = dataModel.time;
- // vc.VideoDataMode = VideoDataMode;
- // [self.navigationController pushViewController:vc animated:YES];
-
- NASFileAudioDataModel*dataModel = _curNASFileAudioMod.data.list[row];
- audioPlayerViewController * vc = [audioPlayerViewController new];
- vc.isfirstEnterType = YES;
- vc.outSideDataModel = dataModel;
- [self.navigationController pushViewController:vc animated:YES];
-
- KWeakSelf
- vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
- [weakSelf deleteNetDataByFilePath:filePath];
- };
- }
- }
- #pragma mark 空数据
- - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
-
- NSString *imageName = @"common_no_data_pic";
-
- return [UIImage imageNamed:imageName];
- }
- - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
- NSString *text = NSLocalizedString(@"common_no_data_tip",nil);
-
- NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
- NSForegroundColorAttributeName: HW999999Color};
-
- return [[NSAttributedString alloc] initWithString:text attributes:attributes];
- }
- //调整图片位置
- - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
- return -150;
- }
- //ios端:
- //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
- //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
- //ios支持图片格式: (SVG 不支持)
- //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
- //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
- - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
- NSString*name = [fileModel.name lowercaseString];
- NSArray *nameArr = [name componentsSeparatedByString:@"."];
- if(nameArr.count >0 && !_isAudioType){
- BOOL canDownLoadType = NO;
-
- NSString *lastName = nameArr.lastObject;
- if([lastName isEqualToString:@"mp4"]
- ||[lastName isEqualToString:@"mov"]
- ||[lastName isEqualToString:@"3gp"]
- ||[lastName isEqualToString:@"m4v"]){
- canDownLoadType = YES;
- }
-
- if(!canDownLoadType){
- if(canShow){
- [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
- }
-
- return NO;
- }
- }
-
- if(nameArr.count >0 && _isAudioType){
- BOOL canDownLoadType = NO;
- //JPG 、PNG、GIF、TIFF、BMP
- NSString *lastName = nameArr.lastObject;
- if([lastName isEqualToString:@"jpg"]
- ||[lastName isEqualToString:@"png"]
- ||[lastName isEqualToString:@"gif"]
- ||[lastName isEqualToString:@"tiff"]
- ||[lastName isEqualToString:@"bmp"]
- ||[lastName isEqualToString:@"heic"]
- ||[lastName isEqualToString:@"jpeg"]
- ||[lastName isEqualToString:@"heif"]){
- canDownLoadType = YES;
- }
-
- if(!canDownLoadType){
- if(canShow){
- [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
- }
- return NO;
- }
- }
-
- return YES;
- }
- #pragma mark 用户长按图片进入编辑
- - (void)setViewEditTypeFun
- {
- _isEditType = YES;
- //[self.tableView reloadData];
-
- _curEditTypeHeadView.hidden = NO;
- _curEditTypeBottomView.hidden = NO;
- _uploadFileButton.hidden = YES;
-
- [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
- }];
- }
- #pragma mark 用户取消编辑编辑
- - (void)userCancelEditTypeFun
- {
- //数据还原
- for (NASFileAudioDataModel*model in _didSelectListArr) {
- model.isSelectType = NO;
- }
- [_didSelectListArr removeAllObjects];
-
- _isEditType = NO;
- [self.tableView reloadData];
-
- _curEditTypeHeadView.hidden = YES;
- _curEditTypeBottomView.hidden = YES;
- _uploadFileButton.hidden = NO;
-
- [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
- }];
- }
- - (void)userCheckFilePreviewByRow:(NSInteger)row
- {
- if(row < _curNASFileAudioMod.data.list.count){
- NASFileAudioDataModel* dataModel = _curNASFileAudioMod.data.list[row];
-
- if(dataModel.isSelectType){
- [_didSelectListArr removeObject:dataModel];
- }
- else{
- [_didSelectListArr addObject:dataModel];
- }
-
- dataModel.isSelectType = !dataModel.isSelectType;
-
- [self setEditTypeTitleFun];
- }
- }
- - (void)didClickSelectAllButton:(UIButton*)button
- {
- //button.selected = !button.selected;
-
- [_didSelectListArr removeAllObjects];
-
- for (NASFileAudioDataModel* dataModel in _curNASFileAudioMod.data.list) {
-
- if(!button.selected){
- dataModel.isSelectType = button.selected;
- }
- else{
- [_didSelectListArr addObject:dataModel];
- dataModel.isSelectType = button.selected;
- }
- }
-
- [self.tableView reloadData];
- //[self.dataCollectionView reloadData];
- [self setEditTypeTitleFun];
- }
- #pragma mark 设置选中标题
- - (void)setEditTypeTitleFun
- {
- [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
-
- if(_didSelectListArr.count > 0){
- [self setViewEditTypeFun];
- }
- else{
- [self userCancelEditTypeFun];
- }
- }
- #pragma mark 用户点击分享
- - (void)gotoShareViewFun
- {
- if (_didSelectListArr.count > 50) {
- [[iToast makeText:NSLocalizedString(@"share_max_count_tip1",nil)] show];
- return;
- }
-
- editShareView *editShareV = [[editShareView alloc] init];
- editShareV.didSelectListArr = _didSelectListArr;
- editShareV.shareFileType = @"4";
- [self.view addSubview:editShareV];
-
- [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
- }
- #pragma mark 用户点击上传文件
- - (void)userDidClickUploadViewFun
- {
- previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
- [self.view addSubview:previewToUploadFileV];
-
- [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- KWeakSelf
- previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
- [weakSelf gotoUploadFileFunWith:tag];
- };
- }
- #pragma mark 设置标题
- - (void)setTitleLabelText:(NSString*)title
- {
- NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
- if(diskNameArr && diskNameArr.count >= 2){
-
- NSString *name = diskNameArr.lastObject;
- if(name.length == 0)
- {
- name = diskNameArr[diskNameArr.count -2];
- }
-
- //name = [name stringByReplacingOccurrencesOfString:@"sdcard" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
- name = [iTools changePathToShowPathBy:name];
-
- title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
- }
-
-
-
- self.MytitleLabel.text = title;
-
- CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
-
- curWidth += 20;
- //HLog(@"title w:%f",curWidth);
- [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
- make.centerY.mas_equalTo(self.backBtn.mas_centerY);
- make.width.mas_equalTo(curWidth);
- make.height.mas_equalTo(30);
- }];
- //self.MytitleLabel.backgroundColor = [UIColor greenColor];
-
- [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
- make.centerY.mas_equalTo(self.backBtn.mas_centerY);
- make.width.mas_equalTo(15);
- make.height.mas_equalTo(15);
- }];
-
- [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
- make.centerY.mas_equalTo(self.backBtn.mas_centerY);
- make.width.mas_equalTo(curWidth+15);
- make.height.mas_equalTo(30);
- }];
- }
- #pragma mark 选择硬盘
- - (void)selectDiskAction:(UIButton*)but
- {
- if(self.diskListBgV.hidden){
- [self showDiskListVieFun];
- }
- else{
- [self hideDiskListVieFun];
-
- }
- }
- - (void)showDiskListVieFun
- {
- self.diskListBgV.hidden = NO;
- self.diskListTableV.hidden = NO;
-
- [UIView animateWithDuration:0.3 animations:^{
- CGRect rect = self.diskListTableV.frame;
- rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
- self.diskListTableV.frame = rect;
- self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
- }];
- }
- - (void)hideDiskListVieFun
- {
- self.diskListBgV.hidden = YES;
-
- [UIView animateWithDuration:0.3 animations:^{
- self.diskListTableV.hidden = YES;
- self.selectTip.transform = CGAffineTransformIdentity;
-
- }completion:^(BOOL finished) {
- CGRect rect = self.diskListTableV.frame;
- rect.origin.y = 0;
- self.diskListTableV.frame = rect;
- }];
- }
- #pragma mark 设置标题
- - (void)setTitleAfterGetdiskFun
- {
- if(_isAudioType){
- [self setTitleLabelText:NSLocalizedString(@"my_set_no_music",nil)];
- }
- else{
- [self setTitleLabelText:NSLocalizedString(@"my_set_no_file",nil)];
- }
-
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [self showDownloadTipFun];
- [self checkFileTransferTask];
-
- if(!_curNASFileAudioMod){
- [self getFileListFun:NO];
- [self queryShareSwitchFunFun];
- }
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
-
- //[self removeNewIndicator];
- [self removeNewIndicatorHaveStr];
- }
- - (void)gotoDownloadloadFileRecordFun
- {
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- vc.isDownloadingType = YES;
- //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
- }
- - (void)showDownloadTipFun
- {
- BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
-
- if(didReadUploadTipType){
- return;
- }
-
-
- //KWeakSelf
- /*弹窗提示恢复出厂*/
- ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
- msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
- imageStr:nil
- cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
- okTitle:nil
- isOkBtnHighlight:NO
- didClickOk:^{
-
- } didClickCancel:^{
- [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
- }];
-
- nextVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self presentViewController:nextVC animated:YES completion:^{
- nextVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
-
- }
- - (void)checkFileTransferTask
- {//有个偶现的闪退在BGFMDB
-
- [[nasUploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
- self->hadUploadTaskType = isSuccess;
- [self setRightButtonRedTypeFun];
- }];
-
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[nasDownloadFileManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
- self->hadDownloadTaskType = isSuccess;
- [weakSelf setRightButtonRedTypeFun];
- }];
- });
-
- }
- - (void)setRightButtonRedTypeFun
- {
- mainBlock(^{
- if(self->hadUploadTaskType || self->hadDownloadTaskType){
- self->rightRedView.hidden = NO;
- }
- else{
- self->rightRedView.hidden = YES;
- }
- });
- }
- - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
- {
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark 获取文件数据
- - (void)getFileListFun:(BOOL)isMoreDataType
- {
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
- if(_isAudioType){
- [paraDict setValue:@"audio" forKey:@"type"];
- }
- else{
- [paraDict setValue:@"file" forKey:@"type"];
- }
-
- // if(!isMoreDataType){
- // self.pageIndex = 0;
- // }
- // else{
- // self.pageIndex ++;
- // }
- //
- // [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
- // [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
- NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
- if(diskNameArr && diskNameArr.count >= 2){
-
- NSString *name = diskNameArr.lastObject;
- if(name.length == 0)
- {
- name = diskNameArr[diskNameArr.count -2];
- }
-
- [paraDict setValue:name forKey:@"path"];
- }
-
- [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
-
- KWeakSelf
- [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileList" Parameters:paraDict success:^(id _Nonnull responseObject) {
- [weakSelf removeNewIndicatorHaveStr];
- //[weakSelf.tableView.mj_footer endRefreshing];
- NASFileAudioModel*NASFileAudioMod = [[NASFileAudioModel alloc] initWithDictionary:responseObject error:nil];
-
- // if(NASFileAudioMod.data.list.count < pageSizeNum){
- // [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
- // }
-
- [weakSelf handelNetDataAfterFilterDataBy:NASFileAudioMod];
- if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
- [weakSelf.tableView reloadData];
- }
-
- } failure:^(NSError * _Nonnull error) {
- [weakSelf removeNewIndicatorHaveStr];
- //[weakSelf.tableView.mj_footer endRefreshing];
- if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
- {
- [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
-
- }
- else{
- [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
- }
- }];
- }
- #pragma mark 上拉或者点击更多数据
- - (void)getMoreNetWorkData
- {
- [self getFileListFun:YES];
- }
- #pragma mark 分页数据组装
- - (void)handelNetDataAfterFilterDataBy:(NASFileAudioModel*)NASFileAudioMod
- {
- if(_curNASFileAudioMod && _curNASFileAudioMod.data && _curNASFileAudioMod.data.list){
- NSMutableArray *handelDataArr = [NSMutableArray arrayWithArray:_curNASFileAudioMod.data.list];//旧数据
- [handelDataArr addObjectsFromArray:NASFileAudioMod.data.list];//新数据
-
- _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)handelDataArr;
- }
- else{
- _curNASFileAudioMod = NASFileAudioMod;
- }
-
- // if(_curNASFileAudioMod.data.list.count == 0 ){
- // self.tableView.mj_footer.hidden = YES;
- // }
- // else{
- // self.tableView.mj_footer.hidden = NO;
- // }
- }
- #pragma mark 调整文件上传
- - (void)gotoUploadFileFunWith:(NSInteger)tag
- {
- if(tag == 10 || tag == 11){
- uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
- if(tag ==10){
- vc.isPhotoType = YES;
- }
- else{
- vc.isPhotoType = NO;
- }
- [self.navigationController pushViewController:vc animated:YES];
- }
- else{
- KWeakSelf
- [[DocumentPickerManager shareManager] openDocumentPickerSuccess:^(NSArray * _Nonnull urls) {
- [weakSelf gotoUploadFileRecordByFileAppWithUrls:urls];
- }];
- }
- }
- #pragma mark 文件下载
- - (void)gotoDownLoadFileFun
- {
- if(_didSelectListArr.count == 0){
- [[iToast makeText:@""] show];
- return;
- }
-
- NSMutableArray *arr = [NSMutableArray new];
- for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
-
- couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
- fileModel.fileType = dataModel.type;
- fileModel.path = dataModel.path;
- fileModel.name = dataModel.name;
- fileModel.length = dataModel.size;
- fileModel.time = dataModel.duration;
-
- [arr addObject:fileModel];
- }
-
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- vc.isDownloadingType = YES;
- [vc gotoDownloadFile:arr];
- }
- #pragma mark 删除图片
- - (void)showDeleteAlearViewFun
- {
- NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
- NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
- KWeakSelf
- ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
- msg:tipStr
- imageStr:nil
- cancelTitle:NSLocalizedString(@"other_cancel",nil)
- okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
- didClickOk:^{
-
- [weakSelf delFileListFun];
- } didClickCancel:^{
-
- }];
-
- curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
-
- [self presentViewController:curAlretVC animated:YES completion:^{
- curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
- }
- #pragma mark 删除文件数据
- - (void)delFileListFun
- {
-
- NSMutableDictionary*paraDict = [NSMutableDictionary new];
-
- NSMutableArray *pathArr = [NSMutableArray new];
- for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
- [pathArr addObject:dataModel.path];
- }
-
- [paraDict setValue:pathArr forKey:@"path"];
-
- [self showNewIndicatorWithCanBack:YES canTouch:NO];
-
- //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
- KWeakSelf //@"delFile"
- [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
- [weakSelf removeNewIndicator];
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.status == 0){
- [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
- [weakSelf didDeleteSucFun];
- }
- else{
-
- }
- } failure:^(NSError * _Nonnull error) {
- [weakSelf removeNewIndicator];
- }];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Music_delete"];
- }
- #pragma mark 删除成功
- - (void)didDeleteSucFun
- {
- //删除最近文件
- for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
- [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
- }
-
- //2.删除已经获取到的网络数据
- [self deleteNetDataByDeleteSucFun];
- [_didSelectListArr removeAllObjects];
- [self setEditTypeTitleFun];
-
- }
- #pragma mark 删除成功后 对应删除原来获取的网络数据
- - (void)deleteNetDataByDeleteSucFun
- {
- NSMutableArray *afterFilterArr = [NSMutableArray new];
- for (NASFileAudioDataModel *model in _curNASFileAudioMod.data.list) {
- if (!model.isSelectType) {
- [afterFilterArr addObject:model];
- }
- }
-
- _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)afterFilterArr;
-
- [self.tableView reloadData];
- }
- #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
- - (void)deleteNetDataByFilePath:(NSString*)filePath
- {
- if(!filePath || filePath.length == 0){
- return;
- }
-
- NSMutableArray *afterFilterArr = [NSMutableArray new];
- for (NASFileAudioDataModel *model in _curNASFileAudioMod.data.list) {
- if (![model.path isEqualToString:filePath]) {
- [afterFilterArr addObject:model];
- }
- }
-
- _curNASFileAudioMod.data.list = (NSArray<NASFileAudioDataModel>*)afterFilterArr;
- [self.tableView reloadData];
- }
- #pragma mark 获取分享开关
- -(void)queryShareSwitchFunFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- [paraDict setValue:@4 forKey:@"type"];
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
- queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
- if(queryShareMod){
- self->canShareType = queryShareMod.data.configValue;
- [weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
- }
-
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark 文件上传跳转上传记录
- - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
- {
- if(!urls || urls.count){
- return;
- }
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- vc.isUploadingType = YES;
- [vc gotoUploadFileByFileApp:urls];
-
- }
- @end
|