uploadImageOrVideoViewController.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  138. for (int i= 0; i<self.assets.count; i++) {
  139. TZAssetModel *model = self.assets[i];
  140. if(i == self.assets.count -1){
  141. [self didSelectModel:model isLastModel:YES];
  142. }
  143. else{
  144. [self didSelectModel:model isLastModel:NO];
  145. }
  146. }
  147. // for (TZAssetModel *model in self.assets) {
  148. // [self didSelectModel:model isLastModel:NO];
  149. // }
  150. }
  151. else{
  152. for (TZAssetModel *model in self.assets) {
  153. model.isSelected = NO;
  154. }
  155. [self.indexPathsForSelectedItems removeAllObjects];
  156. }
  157. [self refreshAllDataFun];
  158. }
  159. #pragma mark 判断手机相册权限
  160. - (void)checkVideoAccessFun
  161. {
  162. AVAuthorizationStatus authStatus =[AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  163. //判断摄像头状态是否可用
  164. if(authStatus==AVAuthorizationStatusAuthorized){
  165. _isNotAllowed = NO;
  166. }else{
  167. NSLog(@"未开启相机权限,请前往设置中开启");
  168. [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
  169. if (granted){
  170. self->_isNotAllowed = NO;
  171. // mainBlock(^{
  172. //
  173. // });
  174. }
  175. }];
  176. }
  177. //相册权限
  178. if (![[TZImageManager manager] authorizationStatusAuthorized]){
  179. [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
  180. if(status == PHAuthorizationStatusAuthorized){
  181. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  182. [self.photoGroupView setupGroup];
  183. [self delayedSetPhotoGroupViewFrameFun];
  184. });
  185. }
  186. }];
  187. }
  188. }
  189. /**
  190. * 照片列表
  191. */
  192. - (void)setupPhotoListView {
  193. AJPhotoListView *collectionView = [[AJPhotoListView alloc] init];
  194. collectionView.dataSource = self;
  195. collectionView.delegate = self;
  196. collectionView.translatesAutoresizingMaskIntoConstraints = NO;
  197. [self.view insertSubview:collectionView atIndex:0];
  198. self.photoListView = collectionView;
  199. [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  200. make.left.mas_equalTo(0);
  201. make.right.mas_equalTo(0);
  202. make.bottom.mas_equalTo(-(60 + safeArea));
  203. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
  204. }];
  205. }
  206. /**
  207. * 照片列表
  208. */
  209. - (void)setupUploadFileBottomView
  210. {
  211. uploadFileBottomView *bottomView = [[uploadFileBottomView alloc] init];
  212. [self.view insertSubview:bottomView atIndex:0];
  213. self.uploadFileBottomV = bottomView;
  214. [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  215. make.left.mas_equalTo(0);
  216. make.right.mas_equalTo(0);
  217. make.bottom.mas_equalTo(0);
  218. make.height.mas_equalTo(60 + safeArea);
  219. }];
  220. KWeakSelf
  221. bottomView.didClickUploadFile = ^{
  222. [weakSelf gotoUploadFileRecordFun];
  223. };
  224. bottomView.didClickbottomFun = ^{
  225. [weakSelf gotofileTransferPathCheckVCFun];
  226. };
  227. }
  228. /**
  229. * 相册
  230. */
  231. - (void)setupGroupView {
  232. AJPhotoGroupView *photoGroupView = [[AJPhotoGroupView alloc] init];
  233. photoGroupView.my_delegate = self;
  234. photoGroupView.isPhotoType = _isPhotoType;
  235. [self.view insertSubview:photoGroupView belowSubview:self.navBarBGView];
  236. self.photoGroupView = photoGroupView;
  237. photoGroupView.hidden = YES;
  238. photoGroupView.translatesAutoresizingMaskIntoConstraints = NO;
  239. [self.photoGroupView setupGroup];
  240. [self delayedSetPhotoGroupViewFrameFun];
  241. }
  242. #pragma mark 延时设置photoGroupView frame
  243. - (void)delayedSetPhotoGroupViewFrameFun
  244. {
  245. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  246. NSInteger maxCount = 6;
  247. if(self.photoGroupView.albumGroups.count < maxCount){
  248. maxCount = self.photoGroupView.albumGroups.count;
  249. }
  250. [self.photoGroupView mas_remakeConstraints:^(MASConstraintMaker *make) {
  251. make.left.mas_equalTo(0);
  252. make.right.mas_equalTo(0);
  253. make.height.mas_equalTo(60.0 * maxCount);
  254. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
  255. }];
  256. });
  257. }
  258. #pragma mark - 相册切换
  259. - (void)selectGroupAction:(UIButton *)sender {
  260. //无权限
  261. if (self.isNotAllowed) {
  262. return;
  263. }
  264. if (self.photoGroupView.hidden) {
  265. [self bgMaskView];
  266. self.bgMaskView.hidden = NO;
  267. self.photoGroupView.hidden = NO;
  268. [UIView animateWithDuration:0.3 animations:^{
  269. CGRect rect = self.photoGroupView.frame;
  270. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  271. self.photoGroupView.frame = rect;
  272. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  273. }];
  274. } else {
  275. [self hidenGroupView];
  276. }
  277. }
  278. - (void)hidenGroupView {
  279. //[self.bgMaskView removeFromSuperview];
  280. self.bgMaskView.hidden = YES;
  281. [UIView animateWithDuration:0.3 animations:^{
  282. CGRect rect = self.photoGroupView.frame;
  283. rect.origin.y = -SCREEN_H;
  284. self.photoGroupView.frame = rect;
  285. self.selectTip.transform = CGAffineTransformIdentity;
  286. }completion:^(BOOL finished) {
  287. self.photoGroupView.hidden = YES;
  288. }];
  289. }
  290. #pragma mark - 遮罩背景
  291. - (UIView *)bgMaskView {
  292. if (_bgMaskView == nil) {
  293. UIView *bgMaskView = [[UIView alloc] init];
  294. bgMaskView.alpha = 0.5;
  295. bgMaskView.translatesAutoresizingMaskIntoConstraints = NO;
  296. bgMaskView.backgroundColor = [UIColor blackColor];
  297. //[self.view insertSubview:bgMaskView aboveSubview:self.photoListView];
  298. [self.view insertSubview:bgMaskView belowSubview:self.photoGroupView];
  299. bgMaskView.userInteractionEnabled = YES;
  300. [bgMaskView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBgMaskView:)]];
  301. _bgMaskView = bgMaskView;
  302. [bgMaskView mas_makeConstraints:^(MASConstraintMaker *make) {
  303. make.left.mas_equalTo(0);
  304. make.right.mas_equalTo(0);
  305. make.bottom.mas_equalTo(0);
  306. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
  307. }];
  308. }
  309. return _bgMaskView;
  310. }
  311. - (void)tapBgMaskView:(UITapGestureRecognizer *)sender {
  312. if (!self.photoGroupView.hidden) {
  313. [self hidenGroupView];
  314. }
  315. }
  316. #pragma mark - BoPhotoGroupViewProtocol
  317. - (void)didSelectGroup:(TZAlbumModel *)model {
  318. [self loadAssets:model];
  319. [self setTitleLabelText:model.name];
  320. [self hidenGroupView];
  321. }
  322. //加载图片
  323. - (void)loadAssets:(TZAlbumModel *)model {
  324. [self.indexPathsForSelectedItems removeAllObjects];
  325. [self.assets removeAllObjects];
  326. [[TZImageManager manager] getAssetsFromFetchResult:model.result completion:^(NSArray<TZAssetModel *> *models) {
  327. self->_assets = [NSMutableArray arrayWithArray:models];
  328. [self.photoListView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
  329. [self.photoListView reloadData];
  330. }];
  331. }
  332. #pragma mark - uicollectionDelegate
  333. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  334. return self.assets.count;
  335. }
  336. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  337. static NSString *cellIdentifer = @"cell";
  338. AJPhotoListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifer forIndexPath:indexPath];
  339. BOOL isSelected = [self.indexPathsForSelectedItems containsObject:self.assets[indexPath.row]];
  340. [cell bind:self.assets[indexPath.row] selectionFilter:self.selectionFilter isSelected:isSelected];
  341. KWeakSelf
  342. cell.didClckSelectBut = ^(BOOL isSelect) {
  343. [weakSelf handlCellSelectFunBy:indexPath];
  344. };
  345. return cell;
  346. }
  347. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  348. return UIEdgeInsetsMake(5, 5, 5, 5);
  349. }
  350. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  351. CGFloat wh = (collectionView.bounds.size.width - 20)/3.0;
  352. return CGSizeMake(wh, wh);
  353. }
  354. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  355. return 5.0;
  356. }
  357. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  358. return 5.0;
  359. }
  360. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  361. PhotoPreviewViewController *vc =[PhotoPreviewViewController new];
  362. vc.assets = _assets;
  363. vc.currentIndex = indexPath.row;
  364. vc.indexPathsForSelectedItems = _indexPathsForSelectedItems;
  365. vc.maximumNumberOfSelection = _maximumNumberOfSelection;
  366. vc.minimumNumberOfSelection = _minimumNumberOfSelection;
  367. vc.availableStorage = self.uploadFileBottomV.availableStorage;
  368. [self.navigationController pushViewController:vc animated:YES];
  369. KWeakSelf
  370. vc.changeSelectIndex = ^(NSMutableArray * _Nonnull indexPathsForSelectedItems) {
  371. [weakSelf refreshDataAndUIFunWith:indexPathsForSelectedItems];
  372. };
  373. }
  374. #pragma mark 从详情页回来 刷新数据和UI
  375. - (void)refreshDataAndUIFunWith:(NSMutableArray *)indexPathsForSelectedItems
  376. {
  377. self.indexPathsForSelectedItems = indexPathsForSelectedItems;
  378. [self refreshAllDataFun];
  379. }
  380. #pragma mark 刷新所有数据
  381. - (void)refreshAllDataFun
  382. {
  383. [self setDataToBottomViewFun];
  384. [self.photoListView reloadData];
  385. }
  386. #pragma mark 处理点击选中相关
  387. - (void)handlCellSelectFunBy:(NSIndexPath *)indexPath
  388. {
  389. AJPhotoListCell *cell = (AJPhotoListCell *)[self.photoListView cellForItemAtIndexPath:indexPath];
  390. TZAssetModel *model = self.assets[indexPath.row];
  391. //超出最大限制
  392. if (self.indexPathsForSelectedItems.count >= self.maximumNumberOfSelection ) {
  393. return;
  394. }
  395. //取消选中
  396. if ([self.indexPathsForSelectedItems containsObject:model]) {
  397. [self.indexPathsForSelectedItems removeObject:model];
  398. model.isSelected = NO;
  399. [cell isSelected:NO];
  400. }
  401. else
  402. {//选中
  403. [self didSelectModel:model isLastModel:NO];
  404. [cell isSelected:YES];
  405. }
  406. [self setDataToBottomViewFun];
  407. }
  408. #pragma mark 选中某个cell
  409. - (void)didSelectModel:(TZAssetModel *)model isLastModel:(BOOL)isLast
  410. {//选中
  411. [self.indexPathsForSelectedItems addObject:model];
  412. model.isSelected = YES;
  413. if(!model.totalBytes)
  414. {
  415. [[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
  416. // 直接得到最终的 NSData 数据
  417. if (imageData) {
  418. //model.imageData = imageData;
  419. model.totalBytes = [imageData length];
  420. }
  421. if(model.type != TZAssetModelMediaTypeVideo){
  422. [self setDataToBottomViewFun];
  423. }
  424. if(isLast){
  425. mainBlock(^{
  426. [self removeNewIndicator];
  427. });
  428. }
  429. }];
  430. if(model.type == TZAssetModelMediaTypeVideo){
  431. PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
  432. options.version = PHVideoRequestOptionsVersionOriginal;
  433. [[PHImageManager defaultManager] requestAVAssetForVideo:model.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
  434. if ([asset isKindOfClass:[AVURLAsset class]]) {
  435. AVURLAsset* urlAsset = (AVURLAsset*)asset;
  436. //NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL];
  437. NSNumber *size;
  438. [urlAsset.URL getResourceValue:&size forKey:NSURLFileSizeKey error:nil];
  439. //NSLog(@"size is %f",[size floatValue]/(1024.0*1024.0));
  440. //model.videoData = videoData;
  441. //model.totalBytes = [videoData length];
  442. model.totalBytes = size.longLongValue;
  443. [self setDataToBottomViewFun];
  444. if(isLast){
  445. mainBlock(^{
  446. [self removeNewIndicator];
  447. });
  448. }
  449. }
  450. }];
  451. }
  452. }
  453. }
  454. #pragma mark 同步数据到底部
  455. - (void)setDataToBottomViewFun
  456. {
  457. mainBlock(^{
  458. self.uploadFileBottomV.indexPathsForSelectedItems = self.indexPathsForSelectedItems;
  459. });
  460. }
  461. #pragma mark - getter/setter
  462. - (NSMutableArray *)assets {
  463. if (!_assets) {
  464. _assets = [[NSMutableArray alloc] init];
  465. }
  466. return _assets;
  467. }
  468. - (NSMutableArray *)indexPathsForSelectedItems {
  469. if (!_indexPathsForSelectedItems) {
  470. _indexPathsForSelectedItems = [[NSMutableArray alloc] init];
  471. }
  472. return _indexPathsForSelectedItems;
  473. }
  474. #pragma mark 跳转上传记录
  475. - (void)gotoUploadFileRecordFun
  476. {
  477. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  478. [self.navigationController pushViewController:vc animated:YES];
  479. vc.isUploadingType = YES;
  480. [vc gotoUploadFile:_indexPathsForSelectedItems];
  481. }
  482. - (void)getCouldPhoneBaseInfoFun:(NSNotification*)not
  483. {
  484. baseInfoModel = [not object];
  485. //HLog(@"%@",baseInfoModel);
  486. [self handelAfterGetBaseInfoModelData];
  487. }
  488. - (void)handelAfterGetBaseInfoModelData
  489. {
  490. if(!baseInfoModel || ![baseInfoModel isKindOfClass:[couldPhoneBaseInfoModel class]]){
  491. return;
  492. }
  493. NSString * uploadDefaultPath = [HWDataManager getStringWithKey:Const_photo_upload_default_path];
  494. BOOL isExtraFileType = NO;
  495. BOOL isExtraPathFind = NO;
  496. if(uploadDefaultPath){
  497. if(![uploadDefaultPath containsString:@"sdcard/"]){
  498. isExtraFileType = YES;
  499. }
  500. }
  501. if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){
  502. NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  503. for (cloudPhoneExtraFileModel*model in arr) {
  504. if([uploadDefaultPath containsString:model.extraPath]){
  505. NSString * availableStorage = @"";
  506. NSInteger totalSize_k = model.extraAvableSize / 1024;
  507. if(totalSize_k < 1024){
  508. availableStorage = [[NSString alloc] initWithFormat:@"%ldKB",totalSize_k];
  509. }
  510. else if( totalSize_k >= 1024 && totalSize_k < 1024*1024){
  511. availableStorage = [[NSString alloc] initWithFormat:@"%.1fMB",totalSize_k/1024.0];
  512. }
  513. else{
  514. availableStorage = [[NSString alloc] initWithFormat:@"%.2fG",totalSize_k/1024.0/1024.0];
  515. }
  516. self.uploadFileBottomV.availableStorage = availableStorage;
  517. self.uploadFileBottomV.available = model.extraAvableSize;
  518. isExtraPathFind = YES;
  519. break;
  520. }
  521. }
  522. }
  523. if(!isExtraFileType){
  524. self.uploadFileBottomV.availableStorage = baseInfoModel.data.availableStorage;
  525. self.uploadFileBottomV.available = baseInfoModel.data.available;
  526. }
  527. if(isExtraFileType && !isExtraPathFind){
  528. self.uploadFileBottomV.isExtraFileAndNotFindPathType = YES;
  529. }
  530. else{
  531. self.uploadFileBottomV.isExtraFileAndNotFindPathType = NO;
  532. }
  533. [self setDataToBottomViewFun];
  534. }
  535. - (void)gotofileTransferPathCheckVCFun
  536. {
  537. fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
  538. vc.curType = 1;
  539. [self.navigationController pushViewController:vc animated:YES];
  540. KWeakSelf
  541. vc.didChangeSavePathFun = ^{
  542. [weakSelf.uploadFileBottomV setSavePathDataFun];
  543. [weakSelf handelAfterGetBaseInfoModelData];
  544. };
  545. }
  546. @end