Commit 7e9114aa authored by 翟书觅's avatar 翟书觅

代码规范命名和规范格式

parent b2f67e49
...@@ -194,13 +194,15 @@ ...@@ -194,13 +194,15 @@
}]; }];
if (_model.type == TZAssetCellTypeVideo) { if (_model.type == TZAssetCellTypeVideo) {
[[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) { [[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{ if (!playerItem && [info[PHImageResultIsInCloudKey] boolValue]) {
self->_model.iCloudFailed = YES; dispatch_async(dispatch_get_main_queue(), ^{
if (self->_didSelectPhotoBlock) { self->_model.iCloudFailed = YES;
self->_didSelectPhotoBlock(YES); if (self->_didSelectPhotoBlock) {
self->_selectImageView.image = self.photoDefImage; self->_didSelectPhotoBlock(YES);
} self->_selectImageView.image = self.photoDefImage;
}); }
});
}
}]; }];
} }
} }
......
...@@ -566,11 +566,11 @@ static CGFloat itemMargin = 5; ...@@ -566,11 +566,11 @@ static CGFloat itemMargin = 5;
[[NSNotificationCenter defaultCenter] postNotificationName:@"TZ_PHOTO_PICKER_RELOAD_NOTIFICATION" object:strongSelf.navigationController]; [[NSNotificationCenter defaultCenter] postNotificationName:@"TZ_PHOTO_PICKER_RELOAD_NOTIFICATION" object:strongSelf.navigationController];
} }
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller]; [UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
if (strongCell.model.iCloudFailed) { if (strongCell.model.iCloudFailed) {
[strongSelf->_models replaceObjectAtIndex:indexPath.item withObject:strongCell.model]; [strongSelf->_models replaceObjectAtIndex:indexPath.item withObject:strongCell.model];
NSString *title = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"]; NSString *title = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"];
[tzImagePickerVc showAlertWithTitle:title]; [tzImagePickerVc showAlertWithTitle:title];
} }
} else { } else {
// 2. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制 // 2. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
if (tzImagePickerVc.selectedModels.count < tzImagePickerVc.maxImagesCount) { if (tzImagePickerVc.selectedModels.count < tzImagePickerVc.maxImagesCount) {
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
@property (nonatomic, strong) UIScrollView *scrollView; @property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *imageContainerView; @property (nonatomic, strong) UIView *imageContainerView;
@property (nonatomic, strong) TZProgressView *progressView; @property (nonatomic, strong) TZProgressView *progressView;
@property (nonatomic, strong) UIImageView *icloudErrorIcon; @property (nonatomic, strong) UIImageView *iCloudErrorIcon;
@property (nonatomic, strong) UILabel *icloudErrorLB; @property (nonatomic, strong) UILabel *iCloudErrorLabel;
@property (nonatomic, copy) void (^iCloudSyncFailed)(id asset, BOOL isSyncFailed); @property (nonatomic, copy) void (^iCloudSyncFailedHandle)(id asset, BOOL isSyncFailed);
@property (nonatomic, assign) BOOL allowCrop; @property (nonatomic, assign) BOOL allowCrop;
...@@ -64,9 +64,9 @@ ...@@ -64,9 +64,9 @@
@property (strong, nonatomic) UIButton *playButton; @property (strong, nonatomic) UIButton *playButton;
@property (strong, nonatomic) UIImage *cover; @property (strong, nonatomic) UIImage *cover;
@property (nonatomic, strong) NSURL *videoURL; @property (nonatomic, strong) NSURL *videoURL;
@property (nonatomic, strong) UIImageView *icloudErrorIcon; @property (nonatomic, strong) UIImageView *iCloudErrorIcon;
@property (nonatomic, strong) UILabel *icloudErrorLB; @property (nonatomic, strong) UILabel *iCloudErrorLabel;
@property (nonatomic, copy) void (^iCloudSyncFailed)(id asset, BOOL isSyncFailed); @property (nonatomic, copy) void (^iCloudSyncFailedHandle)(id asset, BOOL isSyncFailed);
- (void)pausePlayerAndShowNaviBar; - (void)pausePlayerAndShowNaviBar;
@end @end
......
...@@ -135,16 +135,16 @@ ...@@ -135,16 +135,16 @@
_imageView.clipsToBounds = YES; _imageView.clipsToBounds = YES;
[_imageContainerView addSubview:_imageView]; [_imageContainerView addSubview:_imageView];
_icloudErrorIcon = [[UIImageView alloc] init]; _iCloudErrorIcon = [[UIImageView alloc] init];
_icloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"]; _iCloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"];
_icloudErrorIcon.hidden = YES; _iCloudErrorIcon.hidden = YES;
[self addSubview:_icloudErrorIcon]; [self addSubview:_iCloudErrorIcon];
_icloudErrorLB = [[UILabel alloc] init]; _iCloudErrorLabel = [[UILabel alloc] init];
_icloudErrorLB.font = [UIFont systemFontOfSize:10]; _iCloudErrorLabel.font = [UIFont systemFontOfSize:10];
_icloudErrorLB.textColor = [UIColor whiteColor]; _iCloudErrorLabel.textColor = [UIColor whiteColor];
_icloudErrorLB.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"]; _iCloudErrorLabel.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"];
_icloudErrorLB.hidden = YES; _iCloudErrorLabel.hidden = YES;
[self addSubview:_icloudErrorLB]; [self addSubview:_iCloudErrorLabel];
UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)]; UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)];
[self addGestureRecognizer:tap1]; [self addGestureRecognizer:tap1];
...@@ -171,15 +171,11 @@ ...@@ -171,15 +171,11 @@
if (model.type == TZAssetModelMediaTypePhotoGif) { if (model.type == TZAssetModelMediaTypePhotoGif) {
// 先显示缩略图 // 先显示缩略图
[[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { [[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) { BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self->_icloudErrorLB.hidden = NO; self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self->_icloudErrorIcon.hidden = NO; self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
} else { if (self.iCloudSyncFailedHandle) {
self->_icloudErrorLB.hidden = YES; self.iCloudSyncFailedHandle(model.asset, iCloudSyncFailed);
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(model.asset, !self->_icloudErrorLB.hidden);
} }
if (photo) { if (photo) {
self.imageView.image = photo; self.imageView.image = photo;
...@@ -228,15 +224,11 @@ ...@@ -228,15 +224,11 @@
_asset = asset; _asset = asset;
self.imageRequestID = [[TZImageManager manager] getPhotoWithAsset:asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { self.imageRequestID = [[TZImageManager manager] getPhotoWithAsset:asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) { BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self->_icloudErrorLB.hidden = NO; self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self->_icloudErrorIcon.hidden = NO; self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
} else { if (self.iCloudSyncFailedHandle) {
self->_icloudErrorLB.hidden = YES; self.iCloudSyncFailedHandle(asset, iCloudSyncFailed);
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(asset, !self->_icloudErrorLB.hidden);
} }
if (![asset isEqual:self->_asset]) return; if (![asset isEqual:self->_asset]) return;
if (photo) { if (photo) {
...@@ -252,7 +244,7 @@ ...@@ -252,7 +244,7 @@
[self.scrollView setZoomScale:scale animated:YES]; [self.scrollView setZoomScale:scale animated:YES];
} }
} }
self->_progressView.hidden = YES; self->_progressView.hidden = YES;
if (self.imageProgressUpdateBlock) { if (self.imageProgressUpdateBlock) {
self.imageProgressUpdateBlock(1); self.imageProgressUpdateBlock(1);
...@@ -350,8 +342,8 @@ ...@@ -350,8 +342,8 @@
CGFloat progressY = (self.tz_height - progressWH) / 2; CGFloat progressY = (self.tz_height - progressWH) / 2;
_progressView.frame = CGRectMake(progressX, progressY, progressWH, progressWH); _progressView.frame = CGRectMake(progressX, progressY, progressWH, progressWH);
[self recoverSubviews]; [self recoverSubviews];
_icloudErrorIcon.frame = CGRectMake(20, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, 28, 28); _iCloudErrorIcon.frame = CGRectMake(20, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, 28, 28);
_icloudErrorLB.frame = CGRectMake(53, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, self.tz_width - 63, 28); _iCloudErrorLabel.frame = CGRectMake(53, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, self.tz_width - 63, 28);
} }
#pragma mark - UITapGestureRecognizer Event #pragma mark - UITapGestureRecognizer Event
...@@ -408,14 +400,14 @@ ...@@ -408,14 +400,14 @@
- (void)configSubviews { - (void)configSubviews {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil];
_icloudErrorIcon = [[UIImageView alloc] init]; _iCloudErrorIcon = [[UIImageView alloc] init];
_icloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"]; _iCloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"];
_icloudErrorIcon.hidden = YES; _iCloudErrorIcon.hidden = YES;
_icloudErrorLB = [[UILabel alloc] init]; _iCloudErrorLabel = [[UILabel alloc] init];
_icloudErrorLB.font = [UIFont systemFontOfSize:10]; _iCloudErrorLabel.font = [UIFont systemFontOfSize:10];
_icloudErrorLB.textColor = [UIColor whiteColor]; _iCloudErrorLabel.textColor = [UIColor whiteColor];
_icloudErrorLB.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"]; _iCloudErrorLabel.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"];
_icloudErrorLB.hidden = YES; _iCloudErrorLabel.hidden = YES;
} }
- (void)configPlayButton { - (void)configPlayButton {
...@@ -427,8 +419,8 @@ ...@@ -427,8 +419,8 @@
[_playButton setImage:[UIImage tz_imageNamedFromMyBundle:@"MMVideoPreviewPlayHL"] forState:UIControlStateHighlighted]; [_playButton setImage:[UIImage tz_imageNamedFromMyBundle:@"MMVideoPreviewPlayHL"] forState:UIControlStateHighlighted];
[_playButton addTarget:self action:@selector(playButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_playButton addTarget:self action:@selector(playButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_playButton]; [self addSubview:_playButton];
[self addSubview:_icloudErrorIcon]; [self addSubview:_iCloudErrorIcon];
[self addSubview:_icloudErrorLB]; [self addSubview:_iCloudErrorLabel];
} }
- (void)setModel:(TZAssetModel *)model { - (void)setModel:(TZAssetModel *)model {
...@@ -451,15 +443,11 @@ ...@@ -451,15 +443,11 @@
if (self.model && self.model.asset) { if (self.model && self.model.asset) {
[[TZImageManager manager] getPhotoWithAsset:self.model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { [[TZImageManager manager] getPhotoWithAsset:self.model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) { BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self->_icloudErrorLB.hidden = NO; self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self->_icloudErrorIcon.hidden = NO; self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
} else { if (self.iCloudSyncFailedHandle) {
self->_icloudErrorLB.hidden = YES; self.iCloudSyncFailedHandle(self.model.asset, iCloudSyncFailed);
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(self.model.asset, !self->_icloudErrorLB.hidden);
} }
if (photo) { if (photo) {
self.cover = photo; self.cover = photo;
...@@ -467,15 +455,11 @@ ...@@ -467,15 +455,11 @@
}]; }];
[[TZImageManager manager] getVideoWithAsset:self.model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) { [[TZImageManager manager] getVideoWithAsset:self.model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (!playerItem && [info[PHImageResultIsInCloudKey] boolValue]) { BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self->_icloudErrorLB.hidden = NO; self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self->_icloudErrorIcon.hidden = NO; self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
} else { if (self.iCloudSyncFailedHandle) {
self->_icloudErrorLB.hidden = YES; self.iCloudSyncFailedHandle(self.model.asset, iCloudSyncFailed);
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(self.model.asset, !self->_icloudErrorLB.hidden);
} }
[self configPlayerWithItem:playerItem]; [self configPlayerWithItem:playerItem];
}); });
...@@ -500,8 +484,8 @@ ...@@ -500,8 +484,8 @@
[super layoutSubviews]; [super layoutSubviews];
_playerLayer.frame = self.bounds; _playerLayer.frame = self.bounds;
_playButton.frame = CGRectMake(0, 64, self.tz_width, self.tz_height - 64 - 44); _playButton.frame = CGRectMake(0, 64, self.tz_width, self.tz_height - 64 - 44);
_icloudErrorIcon.frame = CGRectMake(20, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, 28, 28); _iCloudErrorIcon.frame = CGRectMake(20, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, 28, 28);
_icloudErrorLB.frame = CGRectMake(53, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, self.tz_width - 63, 28); _iCloudErrorLabel.frame = CGRectMake(53, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, self.tz_width - 63, 28);
} }
- (void)photoPreviewCollectionViewDidScroll { - (void)photoPreviewCollectionViewDidScroll {
......
...@@ -460,7 +460,7 @@ ...@@ -460,7 +460,7 @@
if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypeVideo) { if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypeVideo) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZVideoPreviewCell" forIndexPath:indexPath]; cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZVideoPreviewCell" forIndexPath:indexPath];
TZVideoPreviewCell *currentCell = (TZVideoPreviewCell *)cell; TZVideoPreviewCell *currentCell = (TZVideoPreviewCell *)cell;
currentCell.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) { currentCell.iCloudSyncFailedHandle = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed; model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model]; [weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model]; [weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
...@@ -468,7 +468,7 @@ ...@@ -468,7 +468,7 @@
} else if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypePhotoGif && _tzImagePickerVc.allowPickingGif) { } else if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypePhotoGif && _tzImagePickerVc.allowPickingGif) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZGifPreviewCell" forIndexPath:indexPath]; cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZGifPreviewCell" forIndexPath:indexPath];
TZGifPreviewCell *currentCell = (TZGifPreviewCell *)cell; TZGifPreviewCell *currentCell = (TZGifPreviewCell *)cell;
currentCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) { currentCell.previewView.iCloudSyncFailedHandle = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed; model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model]; [weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model]; [weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
...@@ -497,7 +497,7 @@ ...@@ -497,7 +497,7 @@
} }
} }
}]; }];
photoPreviewCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) { photoPreviewCell.previewView.iCloudSyncFailedHandle = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed; model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model]; [weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model]; [weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment