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

代码规范命名和规范格式

parent b2f67e49
......@@ -194,6 +194,7 @@
}];
if (_model.type == TZAssetCellTypeVideo) {
[[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
if (!playerItem && [info[PHImageResultIsInCloudKey] boolValue]) {
dispatch_async(dispatch_get_main_queue(), ^{
self->_model.iCloudFailed = YES;
if (self->_didSelectPhotoBlock) {
......@@ -201,6 +202,7 @@
self->_selectImageView.image = self.photoDefImage;
}
});
}
}];
}
}
......
......@@ -38,9 +38,9 @@
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *imageContainerView;
@property (nonatomic, strong) TZProgressView *progressView;
@property (nonatomic, strong) UIImageView *icloudErrorIcon;
@property (nonatomic, strong) UILabel *icloudErrorLB;
@property (nonatomic, copy) void (^iCloudSyncFailed)(id asset, BOOL isSyncFailed);
@property (nonatomic, strong) UIImageView *iCloudErrorIcon;
@property (nonatomic, strong) UILabel *iCloudErrorLabel;
@property (nonatomic, copy) void (^iCloudSyncFailedHandle)(id asset, BOOL isSyncFailed);
@property (nonatomic, assign) BOOL allowCrop;
......@@ -64,9 +64,9 @@
@property (strong, nonatomic) UIButton *playButton;
@property (strong, nonatomic) UIImage *cover;
@property (nonatomic, strong) NSURL *videoURL;
@property (nonatomic, strong) UIImageView *icloudErrorIcon;
@property (nonatomic, strong) UILabel *icloudErrorLB;
@property (nonatomic, copy) void (^iCloudSyncFailed)(id asset, BOOL isSyncFailed);
@property (nonatomic, strong) UIImageView *iCloudErrorIcon;
@property (nonatomic, strong) UILabel *iCloudErrorLabel;
@property (nonatomic, copy) void (^iCloudSyncFailedHandle)(id asset, BOOL isSyncFailed);
- (void)pausePlayerAndShowNaviBar;
@end
......
......@@ -135,16 +135,16 @@
_imageView.clipsToBounds = YES;
[_imageContainerView addSubview:_imageView];
_icloudErrorIcon = [[UIImageView alloc] init];
_icloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"];
_icloudErrorIcon.hidden = YES;
[self addSubview:_icloudErrorIcon];
_icloudErrorLB = [[UILabel alloc] init];
_icloudErrorLB.font = [UIFont systemFontOfSize:10];
_icloudErrorLB.textColor = [UIColor whiteColor];
_icloudErrorLB.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"];
_icloudErrorLB.hidden = YES;
[self addSubview:_icloudErrorLB];
_iCloudErrorIcon = [[UIImageView alloc] init];
_iCloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"];
_iCloudErrorIcon.hidden = YES;
[self addSubview:_iCloudErrorIcon];
_iCloudErrorLabel = [[UILabel alloc] init];
_iCloudErrorLabel.font = [UIFont systemFontOfSize:10];
_iCloudErrorLabel.textColor = [UIColor whiteColor];
_iCloudErrorLabel.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"];
_iCloudErrorLabel.hidden = YES;
[self addSubview:_iCloudErrorLabel];
UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)];
[self addGestureRecognizer:tap1];
......@@ -171,15 +171,11 @@
if (model.type == TZAssetModelMediaTypePhotoGif) {
// 先显示缩略图
[[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) {
self->_icloudErrorLB.hidden = NO;
self->_icloudErrorIcon.hidden = NO;
} else {
self->_icloudErrorLB.hidden = YES;
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(model.asset, !self->_icloudErrorLB.hidden);
BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
if (self.iCloudSyncFailedHandle) {
self.iCloudSyncFailedHandle(model.asset, iCloudSyncFailed);
}
if (photo) {
self.imageView.image = photo;
......@@ -228,15 +224,11 @@
_asset = asset;
self.imageRequestID = [[TZImageManager manager] getPhotoWithAsset:asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) {
self->_icloudErrorLB.hidden = NO;
self->_icloudErrorIcon.hidden = NO;
} else {
self->_icloudErrorLB.hidden = YES;
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(asset, !self->_icloudErrorLB.hidden);
BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
if (self.iCloudSyncFailedHandle) {
self.iCloudSyncFailedHandle(asset, iCloudSyncFailed);
}
if (![asset isEqual:self->_asset]) return;
if (photo) {
......@@ -350,8 +342,8 @@
CGFloat progressY = (self.tz_height - progressWH) / 2;
_progressView.frame = CGRectMake(progressX, progressY, progressWH, progressWH);
[self recoverSubviews];
_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);
_iCloudErrorIcon.frame = CGRectMake(20, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, 28, 28);
_iCloudErrorLabel.frame = CGRectMake(53, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, self.tz_width - 63, 28);
}
#pragma mark - UITapGestureRecognizer Event
......@@ -408,14 +400,14 @@
- (void)configSubviews {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil];
_icloudErrorIcon = [[UIImageView alloc] init];
_icloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"];
_icloudErrorIcon.hidden = YES;
_icloudErrorLB = [[UILabel alloc] init];
_icloudErrorLB.font = [UIFont systemFontOfSize:10];
_icloudErrorLB.textColor = [UIColor whiteColor];
_icloudErrorLB.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"];
_icloudErrorLB.hidden = YES;
_iCloudErrorIcon = [[UIImageView alloc] init];
_iCloudErrorIcon.image = [UIImage tz_imageNamedFromMyBundle:@"iCloudError"];
_iCloudErrorIcon.hidden = YES;
_iCloudErrorLabel = [[UILabel alloc] init];
_iCloudErrorLabel.font = [UIFont systemFontOfSize:10];
_iCloudErrorLabel.textColor = [UIColor whiteColor];
_iCloudErrorLabel.text = [NSBundle tz_localizedStringForKey:@"iCloud sync failed"];
_iCloudErrorLabel.hidden = YES;
}
- (void)configPlayButton {
......@@ -427,8 +419,8 @@
[_playButton setImage:[UIImage tz_imageNamedFromMyBundle:@"MMVideoPreviewPlayHL"] forState:UIControlStateHighlighted];
[_playButton addTarget:self action:@selector(playButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_playButton];
[self addSubview:_icloudErrorIcon];
[self addSubview:_icloudErrorLB];
[self addSubview:_iCloudErrorIcon];
[self addSubview:_iCloudErrorLabel];
}
- (void)setModel:(TZAssetModel *)model {
......@@ -451,15 +443,11 @@
if (self.model && self.model.asset) {
[[TZImageManager manager] getPhotoWithAsset:self.model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) {
self->_icloudErrorLB.hidden = NO;
self->_icloudErrorIcon.hidden = NO;
} else {
self->_icloudErrorLB.hidden = YES;
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(self.model.asset, !self->_icloudErrorLB.hidden);
BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
if (self.iCloudSyncFailedHandle) {
self.iCloudSyncFailedHandle(self.model.asset, iCloudSyncFailed);
}
if (photo) {
self.cover = photo;
......@@ -467,15 +455,11 @@
}];
[[TZImageManager manager] getVideoWithAsset:self.model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
if (!playerItem && [info[PHImageResultIsInCloudKey] boolValue]) {
self->_icloudErrorLB.hidden = NO;
self->_icloudErrorIcon.hidden = NO;
} else {
self->_icloudErrorLB.hidden = YES;
self->_icloudErrorIcon.hidden = YES;
}
if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(self.model.asset, !self->_icloudErrorLB.hidden);
BOOL iCloudSyncFailed = !photo && [info[PHImageResultIsInCloudKey] boolValue];
self.iCloudErrorLabel.hidden = !iCloudSyncFailed;
self.iCloudErrorIcon.hidden = !iCloudSyncFailed;
if (self.iCloudSyncFailedHandle) {
self.iCloudSyncFailedHandle(self.model.asset, iCloudSyncFailed);
}
[self configPlayerWithItem:playerItem];
});
......@@ -500,8 +484,8 @@
[super layoutSubviews];
_playerLayer.frame = self.bounds;
_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);
_icloudErrorLB.frame = CGRectMake(53, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, self.tz_width - 63, 28);
_iCloudErrorIcon.frame = CGRectMake(20, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, 28, 28);
_iCloudErrorLabel.frame = CGRectMake(53, [TZCommonTools tz_isIPhoneX] ? 88 + 10 : 64 + 10, self.tz_width - 63, 28);
}
- (void)photoPreviewCollectionViewDidScroll {
......
......@@ -460,7 +460,7 @@
if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypeVideo) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZVideoPreviewCell" forIndexPath:indexPath];
TZVideoPreviewCell *currentCell = (TZVideoPreviewCell *)cell;
currentCell.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
currentCell.iCloudSyncFailedHandle = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
......@@ -468,7 +468,7 @@
} else if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypePhotoGif && _tzImagePickerVc.allowPickingGif) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZGifPreviewCell" forIndexPath:indexPath];
TZGifPreviewCell *currentCell = (TZGifPreviewCell *)cell;
currentCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
currentCell.previewView.iCloudSyncFailedHandle = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
......@@ -497,7 +497,7 @@
}
}
}];
photoPreviewCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
photoPreviewCell.previewView.iCloudSyncFailedHandle = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed: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