uploadImageOrVideoViewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. //
  2. // uploadImageOrVideoViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/9.
  6. //
  7. #import "uploadImageOrVideoViewController.h"
  8. #import <AssetsLibrary/AssetsLibrary.h>
  9. #import <AVFoundation/AVFoundation.h>
  10. #import "AJPhotoListView.h"
  11. #import "AJPhotoGroupView.h"
  12. #import "AJPhotoListCell.h"
  13. #import "uploadFileBottomView.h"
  14. #import "PhotoPreviewViewController.h"
  15. #import "TZAssetModel+imageData.h"
  16. #import "uploadFileRecordViewController.h"
  17. #import "couldPhoneBaseInfoModel.h"
  18. #import "fileTransferPathCheckViewController.h"
  19. @interface uploadImageOrVideoViewController ()<AJPhotoGroupViewProtocol,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
  20. {
  21. couldPhoneBaseInfoModel *baseInfoModel;
  22. }
  23. @property (strong, nonatomic) AJPhotoGroupView *photoGroupView;
  24. @property (strong, nonatomic) UILabel *MytitleLabel;
  25. @property (strong, nonatomic) UIImageView *selectTip;
  26. @property (nonatomic) BOOL isNotAllowed;
  27. @property (strong, nonatomic) UIView *bgMaskView;
  28. @property (strong, nonatomic) AJPhotoListView *photoListView;
  29. @property (strong, nonatomic) NSMutableArray *assets;
  30. @property (strong, nonatomic) NSIndexPath *lastAccessed;
  31. @property (strong, nonatomic) uploadFileBottomView *uploadFileBottomV;
  32. //最多选择项
  33. @property (nonatomic, assign) NSInteger maximumNumberOfSelection;
  34. //最少选择项
  35. @property (nonatomic, assign) NSInteger minimumNumberOfSelection;
  36. //是否开启多选
  37. @property (nonatomic, assign) BOOL multipleSelection;
  38. @end
  39. @implementation uploadImageOrVideoViewController
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. // Do any additional setup after loading the view.
  43. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneBaseInfoFun:) name:getCouldPhoneBaseInfoNotification object:nil];
  44. [self.view setBackgroundColor:HWF5F7FAColor];
  45. [self.toolBar setHidden:YES];
  46. [self.navigationBar setHidden:YES];
  47. [self.navBarBGView setHidden:NO];
  48. [self initBaselUIFun];
  49. _isNotAllowed = YES;
  50. _maximumNumberOfSelection = 30;
  51. _minimumNumberOfSelection = 0;
  52. _multipleSelection = YES;
  53. if(!_selectionFilter)
  54. {
  55. _selectionFilter = [NSPredicate predicateWithValue:YES];
  56. }
  57. [self checkVideoAccessFun];
  58. }
  59. - (void)initBaselUIFun
  60. {
  61. [self initNavHeadUIFun];
  62. //列表view
  63. [self setupPhotoListView];
  64. [self setupUploadFileBottomView];
  65. //相册分组
  66. [self setupGroupView];
  67. }
  68. - (void)initNavHeadUIFun
  69. {
  70. //title
  71. UILabel *titleLabel = [[UILabel alloc] init];
  72. titleLabel.textAlignment = NSTextAlignmentCenter;
  73. titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
  74. titleLabel.textColor = [UIColor blackColor];
  75. titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  76. [self.navBarBGView addSubview:titleLabel];
  77. self.MytitleLabel = titleLabel;
  78. //selectTipImageView
  79. UIImageView *selectTip = [[UIImageView alloc] init];
  80. selectTip.image = [UIImage imageNamed:@"upload_image_arrow"];
  81. selectTip.translatesAutoresizingMaskIntoConstraints = NO;
  82. [self.navBarBGView addSubview:selectTip];
  83. self.selectTip = selectTip;
  84. UIButton *tapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  85. tapBtn.backgroundColor = [UIColor clearColor];
  86. tapBtn.translatesAutoresizingMaskIntoConstraints = NO;
  87. [tapBtn addTarget:self action:@selector(selectGroupAction:) forControlEvents:UIControlEventTouchUpInside];
  88. [self.navBarBGView addSubview:tapBtn];
  89. [tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  91. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  92. make.width.mas_equalTo(100);
  93. make.height.mas_equalTo(30);
  94. }];
  95. [self setTitleLabelText:@""];
  96. UIButton *rightBut = [[UIButton alloc] init];
  97. [rightBut setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal];
  98. [rightBut setTitle:NSLocalizedString(@"File_upload_cancel_select_all",nil) forState:UIControlStateSelected];
  99. [rightBut setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  100. rightBut.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  101. [rightBut addTarget:self action:@selector(didClickSelectAllButton:) forControlEvents:UIControlEventTouchUpInside];
  102. [self.navBarBGView addSubview:rightBut];
  103. [rightBut mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.right.mas_equalTo(-20);
  105. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  106. make.width.mas_equalTo(100);
  107. make.height.mas_equalTo(30);
  108. }];
  109. }
  110. #pragma mark 设置相册标题
  111. - (void)setTitleLabelText:(NSString*)title
  112. {
  113. self.MytitleLabel.text = title;
  114. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18.f]} context:nil].size.width;
  115. curWidth += 20;
  116. //HLog(@"title w:%f",curWidth);
  117. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  118. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  119. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  120. make.width.mas_equalTo(curWidth);
  121. make.height.mas_equalTo(30);
  122. }];
  123. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  124. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(2);
  126. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  127. make.width.mas_equalTo(15);
  128. make.height.mas_equalTo(15);
  129. }];
  130. }
  131. #pragma mark 点击全选
  132. - (void)didClickSelectAllButton:(UIButton*)but
  133. {
  134. but.selected = !but.selected;
  135. if(but.selected){
  136. [self.indexPathsForSelectedItems removeAllObjects];
  137. for (TZAssetModel *model in self.assets) {
  138. [self didSelectModel:model];
  139. }
  140. }
  141. else{
  142. for (TZAssetModel *model in self.assets) {
  143. model.isSelected = NO;
  144. }
  145. [self.indexPathsForSelectedItems removeAllObjects];
  146. }
  147. [self refreshAllDataFun];
  148. }
  149. #pragma mark 判断手机相册权限
  150. - (void)checkVideoAccessFun
  151. {
  152. AVAuthorizationStatus authStatus =[AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  153. //判断摄像头状态是否可用
  154. if(authStatus==AVAuthorizationStatusAuthorized){
  155. _isNotAllowed = NO;
  156. }else{
  157. NSLog(@"未开启相机权限,请前往设置中开启");
  158. [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
  159. if (granted){
  160. self->_isNotAllowed = NO;
  161. // mainBlock(^{
  162. //
  163. // });
  164. }
  165. }];
  166. }
  167. //相册权限
  168. if (![[TZImageManager manager] authorizationStatusAuthorized]){
  169. [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
  170. if(status == PHAuthorizationStatusAuthorized){
  171. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  172. [self.photoGroupView setupGroup];
  173. [self delayedSetPhotoGroupViewFrameFun];
  174. });
  175. }
  176. }];
  177. }
  178. }
  179. /**
  180. * 照片列表
  181. */
  182. - (void)setupPhotoListView {
  183. AJPhotoListView *collectionView = [[AJPhotoListView alloc] init];
  184. collectionView.dataSource = self;
  185. collectionView.delegate = self;
  186. collectionView.translatesAutoresizingMaskIntoConstraints = NO;
  187. [self.view insertSubview:collectionView atIndex:0];
  188. self.photoListView = collectionView;
  189. [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  190. make.left.mas_equalTo(0);
  191. make.right.mas_equalTo(0);
  192. make.bottom.mas_equalTo(-(60 + safeArea));
  193. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
  194. }];
  195. }
  196. /**
  197. * 照片列表
  198. */
  199. - (void)setupUploadFileBottomView
  200. {
  201. uploadFileBottomView *bottomView = [[uploadFileBottomView alloc] init];
  202. [self.view insertSubview:bottomView atIndex:0];
  203. self.uploadFileBottomV = bottomView;
  204. [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  205. make.left.mas_equalTo(0);
  206. make.right.mas_equalTo(0);
  207. make.bottom.mas_equalTo(0);
  208. make.height.mas_equalTo(60 + safeArea);
  209. }];
  210. KWeakSelf
  211. bottomView.didClickUploadFile = ^{
  212. [weakSelf gotoUploadFileRecordFun];
  213. };
  214. bottomView.didClickbottomFun = ^{
  215. [weakSelf gotofileTransferPathCheckVCFun];
  216. };
  217. }
  218. /**
  219. * 相册
  220. */
  221. - (void)setupGroupView {
  222. AJPhotoGroupView *photoGroupView = [[AJPhotoGroupView alloc] init];
  223. photoGroupView.my_delegate = self;
  224. photoGroupView.isPhotoType = _isPhotoType;
  225. [self.view insertSubview:photoGroupView belowSubview:self.navBarBGView];
  226. self.photoGroupView = photoGroupView;
  227. photoGroupView.hidden = YES;
  228. photoGroupView.translatesAutoresizingMaskIntoConstraints = NO;
  229. [self.photoGroupView setupGroup];
  230. [self delayedSetPhotoGroupViewFrameFun];
  231. }
  232. #pragma mark 延时设置photoGroupView frame
  233. - (void)delayedSetPhotoGroupViewFrameFun
  234. {
  235. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  236. NSInteger maxCount = 6;
  237. if(self.photoGroupView.albumGroups.count < maxCount){
  238. maxCount = self.photoGroupView.albumGroups.count;
  239. }
  240. [self.photoGroupView mas_remakeConstraints:^(MASConstraintMaker *make) {
  241. make.left.mas_equalTo(0);
  242. make.right.mas_equalTo(0);
  243. make.height.mas_equalTo(60.0 * maxCount);
  244. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
  245. }];
  246. });
  247. }
  248. #pragma mark - 相册切换
  249. - (void)selectGroupAction:(UIButton *)sender {
  250. //无权限
  251. if (self.isNotAllowed) {
  252. return;
  253. }
  254. if (self.photoGroupView.hidden) {
  255. [self bgMaskView];
  256. self.bgMaskView.hidden = NO;
  257. self.photoGroupView.hidden = NO;
  258. [UIView animateWithDuration:0.3 animations:^{
  259. CGRect rect = self.photoGroupView.frame;
  260. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  261. self.photoGroupView.frame = rect;
  262. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  263. }];
  264. } else {
  265. [self hidenGroupView];
  266. }
  267. }
  268. - (void)hidenGroupView {
  269. //[self.bgMaskView removeFromSuperview];
  270. self.bgMaskView.hidden = YES;
  271. [UIView animateWithDuration:0.3 animations:^{
  272. CGRect rect = self.photoGroupView.frame;
  273. rect.origin.y = -SCREEN_H;
  274. self.photoGroupView.frame = rect;
  275. self.selectTip.transform = CGAffineTransformIdentity;
  276. }completion:^(BOOL finished) {
  277. self.photoGroupView.hidden = YES;
  278. }];
  279. }
  280. #pragma mark - 遮罩背景
  281. - (UIView *)bgMaskView {
  282. if (_bgMaskView == nil) {
  283. UIView *bgMaskView = [[UIView alloc] init];
  284. bgMaskView.alpha = 0.5;
  285. bgMaskView.translatesAutoresizingMaskIntoConstraints = NO;
  286. bgMaskView.backgroundColor = [UIColor blackColor];
  287. //[self.view insertSubview:bgMaskView aboveSubview:self.photoListView];
  288. [self.view insertSubview:bgMaskView belowSubview:self.photoGroupView];
  289. bgMaskView.userInteractionEnabled = YES;
  290. [bgMaskView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBgMaskView:)]];
  291. _bgMaskView = bgMaskView;
  292. [bgMaskView mas_makeConstraints:^(MASConstraintMaker *make) {
  293. make.left.mas_equalTo(0);
  294. make.right.mas_equalTo(0);
  295. make.bottom.mas_equalTo(0);
  296. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
  297. }];
  298. }
  299. return _bgMaskView;
  300. }
  301. - (void)tapBgMaskView:(UITapGestureRecognizer *)sender {
  302. if (!self.photoGroupView.hidden) {
  303. [self hidenGroupView];
  304. }
  305. }
  306. #pragma mark - BoPhotoGroupViewProtocol
  307. - (void)didSelectGroup:(TZAlbumModel *)model {
  308. [self loadAssets:model];
  309. [self setTitleLabelText:model.name];
  310. [self hidenGroupView];
  311. }
  312. //加载图片
  313. - (void)loadAssets:(TZAlbumModel *)model {
  314. [self.indexPathsForSelectedItems removeAllObjects];
  315. [self.assets removeAllObjects];
  316. [[TZImageManager manager] getAssetsFromFetchResult:model.result completion:^(NSArray<TZAssetModel *> *models) {
  317. self->_assets = [NSMutableArray arrayWithArray:models];
  318. [self.photoListView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
  319. [self.photoListView reloadData];
  320. }];
  321. }
  322. #pragma mark - uicollectionDelegate
  323. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  324. return self.assets.count;
  325. }
  326. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  327. static NSString *cellIdentifer = @"cell";
  328. AJPhotoListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifer forIndexPath:indexPath];
  329. BOOL isSelected = [self.indexPathsForSelectedItems containsObject:self.assets[indexPath.row]];
  330. [cell bind:self.assets[indexPath.row] selectionFilter:self.selectionFilter isSelected:isSelected];
  331. KWeakSelf
  332. cell.didClckSelectBut = ^(BOOL isSelect) {
  333. [weakSelf handlCellSelectFunBy:indexPath];
  334. };
  335. return cell;
  336. }
  337. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  338. return UIEdgeInsetsMake(5, 5, 5, 5);
  339. }
  340. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  341. CGFloat wh = (collectionView.bounds.size.width - 20)/3.0;
  342. return CGSizeMake(wh, wh);
  343. }
  344. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  345. return 5.0;
  346. }
  347. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  348. return 5.0;
  349. }
  350. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  351. PhotoPreviewViewController *vc =[PhotoPreviewViewController new];
  352. vc.assets = _assets;
  353. vc.currentIndex = indexPath.row;
  354. vc.indexPathsForSelectedItems = _indexPathsForSelectedItems;
  355. vc.maximumNumberOfSelection = _maximumNumberOfSelection;
  356. vc.minimumNumberOfSelection = _minimumNumberOfSelection;
  357. vc.availableStorage = self.uploadFileBottomV.availableStorage;
  358. [self.navigationController pushViewController:vc animated:YES];
  359. KWeakSelf
  360. vc.changeSelectIndex = ^(NSMutableArray * _Nonnull indexPathsForSelectedItems) {
  361. [weakSelf refreshDataAndUIFunWith:indexPathsForSelectedItems];
  362. };
  363. }
  364. #pragma mark 从详情页回来 刷新数据和UI
  365. - (void)refreshDataAndUIFunWith:(NSMutableArray *)indexPathsForSelectedItems
  366. {
  367. self.indexPathsForSelectedItems = indexPathsForSelectedItems;
  368. [self refreshAllDataFun];
  369. }
  370. #pragma mark 刷新所有数据
  371. - (void)refreshAllDataFun
  372. {
  373. [self setDataToBottomViewFun];
  374. [self.photoListView reloadData];
  375. }
  376. #pragma mark 处理点击选中相关
  377. - (void)handlCellSelectFunBy:(NSIndexPath *)indexPath
  378. {
  379. AJPhotoListCell *cell = (AJPhotoListCell *)[self.photoListView cellForItemAtIndexPath:indexPath];
  380. TZAssetModel *model = self.assets[indexPath.row];
  381. //超出最大限制
  382. if (self.indexPathsForSelectedItems.count >= self.maximumNumberOfSelection ) {
  383. return;
  384. }
  385. //取消选中
  386. if ([self.indexPathsForSelectedItems containsObject:model]) {
  387. [self.indexPathsForSelectedItems removeObject:model];
  388. model.isSelected = NO;
  389. [cell isSelected:NO];
  390. }
  391. else
  392. {//选中
  393. [self didSelectModel:model];
  394. [cell isSelected:YES];
  395. }
  396. [self setDataToBottomViewFun];
  397. }
  398. #pragma mark 选中某个cell
  399. - (void)didSelectModel:(TZAssetModel *)model
  400. {//选中
  401. [self.indexPathsForSelectedItems addObject:model];
  402. model.isSelected = YES;
  403. if(!model.totalBytes)
  404. {
  405. [[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
  406. // 直接得到最终的 NSData 数据
  407. if (imageData) {
  408. //model.imageData = imageData;
  409. model.totalBytes = [imageData length];
  410. }
  411. if(model.type != TZAssetModelMediaTypeVideo){
  412. [self setDataToBottomViewFun];
  413. }
  414. }];
  415. if(model.type == TZAssetModelMediaTypeVideo){
  416. PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
  417. options.version = PHVideoRequestOptionsVersionOriginal;
  418. [[PHImageManager defaultManager] requestAVAssetForVideo:model.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
  419. if ([asset isKindOfClass:[AVURLAsset class]]) {
  420. AVURLAsset* urlAsset = (AVURLAsset*)asset;
  421. //NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL];
  422. NSNumber *size;
  423. [urlAsset.URL getResourceValue:&size forKey:NSURLFileSizeKey error:nil];
  424. //NSLog(@"size is %f",[size floatValue]/(1024.0*1024.0));
  425. //model.videoData = videoData;
  426. //model.totalBytes = [videoData length];
  427. model.totalBytes = size.longLongValue;
  428. [self setDataToBottomViewFun];
  429. }
  430. }];
  431. }
  432. }
  433. }
  434. #pragma mark 同步数据到底部
  435. - (void)setDataToBottomViewFun
  436. {
  437. mainBlock(^{
  438. self.uploadFileBottomV.indexPathsForSelectedItems = self.indexPathsForSelectedItems;
  439. });
  440. }
  441. #pragma mark - getter/setter
  442. - (NSMutableArray *)assets {
  443. if (!_assets) {
  444. _assets = [[NSMutableArray alloc] init];
  445. }
  446. return _assets;
  447. }
  448. - (NSMutableArray *)indexPathsForSelectedItems {
  449. if (!_indexPathsForSelectedItems) {
  450. _indexPathsForSelectedItems = [[NSMutableArray alloc] init];
  451. }
  452. return _indexPathsForSelectedItems;
  453. }
  454. #pragma mark 跳转上传记录
  455. - (void)gotoUploadFileRecordFun
  456. {
  457. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  458. [self.navigationController pushViewController:vc animated:YES];
  459. vc.isUploadingType = YES;
  460. [vc gotoUploadFile:_indexPathsForSelectedItems];
  461. }
  462. - (void)getCouldPhoneBaseInfoFun:(NSNotification*)not
  463. {
  464. baseInfoModel = [not object];
  465. //HLog(@"%@",baseInfoModel);
  466. [self handelAfterGetBaseInfoModelData];
  467. }
  468. - (void)handelAfterGetBaseInfoModelData
  469. {
  470. if(!baseInfoModel || ![baseInfoModel isKindOfClass:[couldPhoneBaseInfoModel class]]){
  471. return;
  472. }
  473. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:Const_photo_upload_default_path];
  474. BOOL isExtraFileType = NO;
  475. BOOL isExtraPathFind = NO;
  476. if(uploadDefaultPath){
  477. if(![uploadDefaultPath containsString:@"sdcard/"]){
  478. isExtraFileType = YES;
  479. }
  480. }
  481. if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  482. NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  483. for (cloudPhoneExtraFileModel*model in arr) {
  484. if([uploadDefaultPath containsString:model.extraPath]){
  485. NSString * availableStorage = @"";
  486. NSInteger totalSize_k = model.extraAvableSize / 1024;
  487. if(totalSize_k < 1024){
  488. availableStorage = [[NSString alloc] initWithFormat:@"%ldKB",totalSize_k];
  489. }
  490. else if( totalSize_k >= 1024 && totalSize_k < 1024*1024){
  491. availableStorage = [[NSString alloc] initWithFormat:@"%.1fMB",totalSize_k/1024.0];
  492. }
  493. else{
  494. availableStorage = [[NSString alloc] initWithFormat:@"%.2fG",totalSize_k/1024.0/1024.0];
  495. }
  496. self.uploadFileBottomV.availableStorage = availableStorage;
  497. self.uploadFileBottomV.available = model.extraAvableSize;
  498. isExtraPathFind = YES;
  499. break;
  500. }
  501. }
  502. }
  503. if(!isExtraFileType){
  504. self.uploadFileBottomV.availableStorage = baseInfoModel.data.availableStorage;
  505. self.uploadFileBottomV.available = baseInfoModel.data.available;
  506. }
  507. if(isExtraFileType && !isExtraPathFind){
  508. self.uploadFileBottomV.isExtraFileAndNotFindPathType = YES;
  509. }
  510. [self setDataToBottomViewFun];
  511. }
  512. - (void)gotofileTransferPathCheckVCFun
  513. {
  514. fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
  515. vc.curType = 1;
  516. [self.navigationController pushViewController:vc animated:YES];
  517. KWeakSelf
  518. vc.didChangeSavePathFun = ^{
  519. [weakSelf.uploadFileBottomV setSavePathDataFun];
  520. };
  521. }
  522. @end