12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361 |
- //
- // previewImageOrVideoViewController.m
- // Private-X
- //
- // Created by xd h on 2024/5/13.
- //
- #import "previewImageOrVideoViewController.h"
- #import "couldPhoneFileListModel.h"
- #import "downloadManager.h"
- #import "uploadFileRecordViewController.h"
- #import "UIScrollView+EmptyDataSet.h"
- #import "diskListBgView.h"
- #import "diskListTableView.h"
- #import "imageCollectionViewCell.h"
- #import "titleLabelReusableView.h"
- #import "editTypeHeadView.h"
- #import "editTypeBottomView.h"
- #import "editShareView.h"
- #import "previewToUploadFileView.h"
- #import "NASFilePicModel.h"
- #import "imageDetailsScrollViewController.h"
- #import "queryShareModel.h"
- #import "videoPlayViewController.h"
- #import "videoPlayByAVPlayerViewController.h"
- #import "MJRefresh.h"
- #import "DocumentPickerManager.h"
- @interface previewImageOrVideoViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
- {
- UIButton *tapBtn;
-
- UIButton* rightTransferListButton;//传输列表
- UIView* rightRedView;
-
- BOOL hadUploadTaskType;
- BOOL hadDownloadTaskType;
-
- BOOL canShareType;
- }
- @property (nonatomic, strong) UICollectionView *dataCollectionView;
- @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) couldPhoneFileListModel *curCouldPhoneFileListMod;
- @property(nonatomic,strong) NASFilePicModel *curNASFilePicModel;
- @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
- @end
- @implementation previewImageOrVideoViewController
- - (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:@"Image"];
- }
- - (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.dataCollectionView];
- [self.dataCollectionView 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_image_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 - 懒加载
- - (UICollectionView *)dataCollectionView{
- if (!_dataCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- // 设置item的行间距和列间距
- layout.minimumInteritemSpacing = 1;
- layout.minimumLineSpacing = 1;
- // 设置item的大小
- CGFloat itemW = ([UIScreen mainScreen].bounds.size.width - 10) /4 ;
- layout.itemSize = CGSizeMake(itemW, itemW);
- layout.headerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 40);
- //layout.footerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 40);
- // 设置每个分区的 上左下右 的内边距
- layout.sectionInset = UIEdgeInsetsMake(1, 1 ,1, 1);
- // 设置区头和区尾的大小
- layout.headerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 10);
- //layout.footerReferenceSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 10);
- // 设置分区的头视图和尾视图 是否始终固定在屏幕上边和下边
- layout.sectionFootersPinToVisibleBounds = YES;
- //设置滚动条方向
- layout.scrollDirection = UICollectionViewScrollDirectionVertical;
-
- _dataCollectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
- _dataCollectionView.backgroundColor = [UIColor whiteColor];
- _dataCollectionView.scrollEnabled = YES;
-
- //注册cell
- [_dataCollectionView registerClass:[imageCollectionViewCell class] forCellWithReuseIdentifier:@"imageCollectionViewCell"];
-
- [_dataCollectionView registerClass:[titleLabelReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"titleLabelReusableView"];
- _dataCollectionView.delegate = self;
- _dataCollectionView.dataSource = self;
-
- //空数据引入第三方开源处理
- _dataCollectionView.emptyDataSetSource = self;
- _dataCollectionView.emptyDataSetDelegate = self;
-
- // 下拉追加
- // MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
- // [self getMoreNetWorkData];
- // }];
- //
- // NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
- // [footer setTitle:text forState:MJRefreshStateNoMoreData];
- // _dataCollectionView.mj_footer = footer;
- }
-
- return _dataCollectionView;
- }
- - (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_image_pre_disk_check value:pathStr];
- }
-
- self.defaultDiskPath = pathStr;
- _curNASFilePicModel = nil;
- [self getFileListFun:NO];
- [self setTitleAfterGetdiskFun];
- [self hideDiskListVieFun];
- }
- #pragma mark - 瀑布流委托
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- if(_curNASFilePicModel){
- return _curNASFilePicModel.data.fileList.count;
- }
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count >section){
- NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
- return timeArrModel.list.count;
- }
- return 0;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- __block NSInteger row = indexPath.row;
- __block NSInteger section = indexPath.section;
- //创建item 从缓存池中拿 Item
- imageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"imageCollectionViewCell" forIndexPath:indexPath];
- if(!cell){
- cell = [[imageCollectionViewCell alloc] init];
- }
-
-
- if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
- NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
- if (timeArrModel.list.count > row) {
- NASFilePicDataArrModel * dataModel = timeArrModel.list[row];
-
- cell.isEditType = _isEditType;
- if(_isPhotoType){
- cell.fileType = @"pic";
- }
- else{
- cell.fileType = @"video";
- }
- cell.curFileModel = dataModel;
-
- KWeakSelf
- cell.didClckSelectBut = ^(BOOL selectType){
- if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
- [weakSelf userCheckFilePreviewByRow:row withSection:section];
- }
- };
-
- cell.didClickEditType = ^(BOOL editType) {
- [weakSelf setViewEditTypeFun];
- };
- }
- }
-
- return cell;
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
- if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
- NSInteger section = indexPath.section;
- titleLabelReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"titleLabelReusableView" forIndexPath:indexPath];
-
- if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
- NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
- headerView.titlelabel.text = timeArrModel.time;
- }
- return headerView;
- }
-
- return nil;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
-
- return CGSizeMake([UIScreen mainScreen].bounds.size.width, 40);
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- NSInteger row = indexPath.row;
- NSInteger section = indexPath.section;
-
- if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
- NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
- if (timeArrModel.list.count > row) {
- //NASFilePicDataArrModel * dataModel = timeArrModel.list[row];
-
- [self didClickPicDetailsWithSection:section withRow:row];
- }
- }
- }
- #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:(NASFilePicDataArrModel*)fileModel withShowTip:(BOOL)canShow{
- // NSString*name = [fileModel.name lowercaseString];
- // NSArray *nameArr = [name componentsSeparatedByString:@"."];
- // if(nameArr.count >0 && !_isPhotoType){
- // 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 && _isPhotoType){
- // 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;
- //[_dataCollectionView reloadData];
-
- _curEditTypeHeadView.hidden = NO;
- _curEditTypeBottomView.hidden = NO;
- _uploadFileButton.hidden = YES;
-
- [self setEditTypeTitleFun];
-
- [self.dataCollectionView 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 (NASFilePicDataArrModel*model in _didSelectListArr) {
- model.isSelectType = NO;
- }
-
- // for (NASFilePicTimeArrModel *timeArrModel in _curNASFilePicModel.data.fileList) {
- // for (NASFilePicDataArrModel *model in timeArrModel.list) {
- // model.isSelectType = NO;
- // }
- // }
- _isEditType = NO;
-
- BOOL isNeedReload = NO;
- if(self->_didSelectListArr.count >0){
- isNeedReload = YES;
- }
-
- [_didSelectListArr removeAllObjects];
-
- if(isNeedReload){
- [_dataCollectionView reloadData];
- }
-
- _curEditTypeHeadView.hidden = YES;
- _curEditTypeBottomView.hidden = YES;
- _uploadFileButton.hidden = NO;
-
- [self.dataCollectionView 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 withSection:(NSInteger)section
- {
- if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
- NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
- if (timeArrModel.list.count > row) {
- NASFilePicDataArrModel * dataModel = timeArrModel.list[row];
- dataModel.isSelectType = !dataModel.isSelectType;
-
- if(!dataModel.isSelectType)
- {
- [_didSelectListArr removeObject:dataModel];
-
- if(_didSelectListArr.count == 0){
- [self userCancelEditTypeFun];
- }
- }
- else{
- [_didSelectListArr addObject:dataModel];
-
- if(_didSelectListArr.count == 1){
- [self setViewEditTypeFun];
- }
- }
-
- [self setEditTypeTitleFun];
-
- }
- }
- }
- - (void)didClickSelectAllButton:(UIButton*)button
- {
- //button.selected = !button.selected;
- BOOL isNeedShowTip = NO;
-
- [_didSelectListArr removeAllObjects];
-
- for (NASFilePicTimeArrModel* fileModel in _curNASFilePicModel.data.fileList) {
-
- for (NASFilePicDataArrModel*dataModel in fileModel.list) {
- if(!button.selected){
- dataModel.isSelectType = button.selected;
- }
- else{
- [_didSelectListArr addObject:dataModel];
- if([self userCheckFileModel:dataModel withShowTip:NO]){
- dataModel.isSelectType = button.selected;
- }
- else{
- isNeedShowTip = YES;
- }
- }
- }
-
- }
-
- // if(isNeedShowTip){
- // if(_isPhotoType){
- // [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
- // }
- // else{
- // [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
- // }
- // }
-
- //[self.tableView reloadData];
- [self.dataCollectionView reloadData];
- [self setEditTypeTitleFun];
- }
- #pragma mark 设置选中标题
- - (void)setEditTypeTitleFun
- {
- [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
-
- BOOL canClick = _didSelectListArr.count >0 ? YES : NO;
- [_curEditTypeBottomView setButtonStateFunBy:canClick];
- }
- #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;
- if(_isPhotoType){
- editShareV.shareFileType = @"2";
- }
- else{
- editShareV.shareFileType = @"3";
- }
- [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(_isPhotoType){
- //self.titleLabel.text = NSLocalizedString(@"my_set_no_image_upload",nil) ;
- [self setTitleLabelText:NSLocalizedString(@"my_set_no_image_upload",nil)];
- }
- else{
- //self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
- [self setTitleLabelText:NSLocalizedString(@"my_set_no_video_upload",nil)];
- }
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
-
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [self showDownloadTipFun];
- [self checkFileTransferTask];
-
- if(!_curNASFilePicModel){
- [self getFileListFun:NO];
- }
-
- }
- - (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(_isPhotoType){
- [paraDict setValue:@"pic" forKey:@"type"];
- }
- else{
- [paraDict setValue:@"video" 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:@"getFileListByDay" Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- //[weakSelf.dataCollectionView.mj_footer endRefreshing];
- [weakSelf removeNewIndicatorHaveStr];
- NASFilePicModel*NASFilePicMod = [[NASFilePicModel alloc] initWithDictionary:responseObject error:nil];
-
- // if(NASFilePicMod.data.fileList.count < pageSizeNum){
- // [weakSelf.dataCollectionView.mj_footer endRefreshingWithNoMoreData];
- // }
-
- [weakSelf filterDataFun:NASFilePicMod];
- [weakSelf.dataCollectionView reloadData];
- } failure:^(NSError * _Nonnull error) {
- [weakSelf removeNewIndicatorHaveStr];
- //[weakSelf.dataCollectionView.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 20230528需求:图片/视频模块,限制50KB以下文件展示;
- - (void)filterDataFun:(NASFilePicModel*)NASFilePicMod
- {
- if(!NASFilePicMod) return;
-
- for (NASFilePicTimeArrModel *timeArrModel in NASFilePicMod.data.fileList) {
- NSMutableArray *afterFilterArr = [NSMutableArray new];
- for (NASFilePicDataArrModel * dataModel in timeArrModel.list) {
- if (dataModel.size > 20*1024) {
- [afterFilterArr addObject:dataModel];
- }
- }
- timeArrModel.list = (NSArray<NASFilePicDataArrModel>*)afterFilterArr;
- }
-
-
- //2.检测是否有空数据组 有则去掉
- NSMutableArray *newFilterArr = [NSMutableArray new];
- for (NASFilePicTimeArrModel *timeArrModel in NASFilePicMod.data.fileList) {
- if(timeArrModel.list.count > 0){
- [newFilterArr addObject:timeArrModel];
- }
- }
-
- NASFilePicMod.data.fileList = (NSArray<NASFilePicTimeArrModel>*)newFilterArr;
-
- [self handelNetDataAfterFilterDataBy:NASFilePicMod];
- }
- #pragma mark 分页数据组装
- - (void)handelNetDataAfterFilterDataBy:(NASFilePicModel*)NASFilePicMod
- {
- NSMutableArray *handelDataArr = [NSMutableArray new];
- if(_curNASFilePicModel && _curNASFilePicModel.data && _curNASFilePicModel.data.fileList){
- [handelDataArr addObjectsFromArray:_curNASFilePicModel.data.fileList];
- }
- else{
- _curNASFilePicModel = [NASFilePicModel new];
- _curNASFilePicModel.data = [NASFilePicSecondModel new];
- }
-
- //数据处理
- for (NASFilePicTimeArrModel *timeArrModel in NASFilePicMod.data.fileList) {
-
- NSString *dataTimeStr = timeArrModel.time;
-
- if(timeArrModel.list > 0){//只处理有数据的 (数据可能被过滤掉)
-
- //全选的时候新加的也选上
-
- BOOL didAddTimeType = NO;//此日期是否存在在数据里面了
- for (NASFilePicTimeArrModel *preTimeArrModel in handelDataArr) {
- NSString *preDataTimeStr = preTimeArrModel.time;
- if([dataTimeStr isEqualToString:preDataTimeStr]){
- didAddTimeType = YES;
-
- NSMutableArray *afterHandelArr = [NSMutableArray new];
- //1.原来数据
- [afterHandelArr addObjectsFromArray:preTimeArrModel.list];
- //2.追加新的数据
- [afterHandelArr addObjectsFromArray:timeArrModel.list];
-
- preTimeArrModel.list = (NSArray<NASFilePicDataArrModel>*)afterHandelArr;
-
- break;
- }
- }
-
- //添加新日期数据
- if(!didAddTimeType){
- [handelDataArr addObject:timeArrModel];
- }
-
- }
-
- }
-
- _curNASFilePicModel.data.fileList = (NSArray<NASFilePicTimeArrModel> *)handelDataArr;
-
- // if(handelDataArr.count == 0 ){
- // _dataCollectionView.mj_footer.hidden = YES;
- // }
- // else{
- // _dataCollectionView.mj_footer.hidden = NO;
- // }
- }
- #pragma mark 点击图片详情
- - (void)didClickPicDetailsWithSection:(NSInteger)section withRow:(NSInteger)row{
-
- if(_curNASFilePicModel){
- NSMutableArray *totalArr = [NSMutableArray new];
- NSInteger index = 0;
-
- for (int i=0; i<_curNASFilePicModel.data.fileList.count; i++) {
- NASFilePicTimeArrModel *timeModel = _curNASFilePicModel.data.fileList[i];
-
- if(i == section){
- index = totalArr.count + row;
- }
-
- [totalArr addObjectsFromArray:timeModel.list];
- }
-
- imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
- vc.index = index;
- vc.totalDataArr = totalArr;
- [self.navigationController pushViewController:vc animated:YES];
- vc.canShareType = canShareType;
-
- KWeakSelf
- vc.didNeedDeleteFile = ^(NSString * _Nonnull filePath) {
- [weakSelf deleteNetDataByFilePath:filePath];
- };
-
- }
- }
- - (void)gotoDownLoadFileFun
- {
- if(_didSelectListArr.count == 0){
- [[iToast makeText:@""] show];
- return;
- }
-
- NSMutableArray *arr = [NSMutableArray new];
- for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
-
- couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
- // if(_isPhotoType){
- // fileModel.fileType = @".jpg";
- // }
- // else{
- // fileModel.fileType = @"video";
- // }
- 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];
- }
- - (void)setIsPhotoType:(BOOL)isPhotoType
- {
- _isPhotoType = isPhotoType;
- [self queryShareSwitchFunFun];
- }
- #pragma mark 获取分享开关
- -(void)queryShareSwitchFunFun
- {
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
-
- if(_isPhotoType){
- [paraDict setValue:@2 forKey:@"type"];
- }
- else{
- [paraDict setValue:@3 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)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)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:@"Image_delete"];
- }
- #pragma mark 删除成功
- - (void)didDeleteSucFun
- {
- //1.删除最近文件
- for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
- [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
- }
-
- //2.删除已经获取到的网络数据
- [self deleteNetDataByDeleteSucFun];
-
- [_didSelectListArr removeAllObjects];
- [self setEditTypeTitleFun];
-
- }
- #pragma mark 删除成功后 对应删除原来获取的网络数据
- - (void)deleteNetDataByDeleteSucFun
- {
- //1.先删除数据
- for (NASFilePicTimeArrModel *timeArrModel in _curNASFilePicModel.data.fileList) {
- NSMutableArray *afterFilterArr = [NSMutableArray new];
- for (NASFilePicDataArrModel * dataModel in timeArrModel.list) {
- if (!dataModel.isSelectType) {
- [afterFilterArr addObject:dataModel];
- }
- }
- timeArrModel.list = (NSArray<NASFilePicDataArrModel>*)afterFilterArr;
- }
-
- //2.检测是否有空数据组 有则去掉
- NSMutableArray *newFilterArr = [NSMutableArray new];
- for (NASFilePicTimeArrModel *timeArrModel in _curNASFilePicModel.data.fileList) {
- if(timeArrModel.list.count > 0){
- [newFilterArr addObject:timeArrModel];
- }
- }
-
- _curNASFilePicModel.data.fileList = (NSArray<NASFilePicTimeArrModel>*)newFilterArr;
-
- [self.dataCollectionView reloadData];
- }
-
- #pragma mark 图片详情删除成功后 对应删除原来获取的网络数据
- - (void)deleteNetDataByFilePath:(NSString*)filePath
- {
- if(!filePath || filePath.length == 0){
- return;
- }
-
- //BOOL didFineFile = NO;
- for (NASFilePicTimeArrModel *timeArrModel in _curNASFilePicModel.data.fileList) {
- NSMutableArray *afterFilterArr = [NSMutableArray new];
- for (NASFilePicDataArrModel * dataModel in timeArrModel.list) {
- if(![dataModel.path isEqualToString:filePath]){
- [afterFilterArr addObject:dataModel];
- }
- else{
- // didFineFile = YES;
- // break;
- }
- }
- timeArrModel.list = (NSArray<NASFilePicDataArrModel>*)afterFilterArr;
-
- // if(didFineFile){
- // break;
- // }
- }
-
- [self.dataCollectionView reloadData];
- }
- #pragma mark 文件上传跳转上传记录
- - (void)gotoUploadFileRecordByFileAppWithUrls:(NSArray*)urls
- {
- if(!urls || urls.count == 0){
- return;
- }
- uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- vc.isUploadingType = YES;
- [vc gotoUploadFileByFileApp:urls];
-
- }
- @end
|