Commit b2f67e49 authored by 翟书觅's avatar 翟书觅

1.视频和图片多选时,添加获取视频信息逻辑

2.根据onlyReturnAsset属性,添加是否提示iCloud同步失败的判断逻辑
parent 900d470d
...@@ -823,7 +823,7 @@ ...@@ -823,7 +823,7 @@
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = LTFQDC2QVX;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)/TZImagePickerController", "$(PROJECT_DIR)/TZImagePickerController",
......
...@@ -169,16 +169,12 @@ ...@@ -169,16 +169,12 @@
_bigImageRequestID = [[TZImageManager manager] requestImageDataForAsset:_model.asset completion:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { _bigImageRequestID = [[TZImageManager manager] requestImageDataForAsset:_model.asset completion:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
if (!imageData && [info[PHImageResultIsInCloudKey] boolValue]) { if (!imageData && [info[PHImageResultIsInCloudKey] boolValue]) {
if (self.model.type == TZAssetModelMediaTypeVideo ||
self.model.type == TZAssetCellTypePhotoGif ||
self.model.type == TZAssetModelMediaTypeLivePhoto) {
self.model.iCloudFailed = YES; self.model.iCloudFailed = YES;
if (self.didSelectPhotoBlock) { if (self.didSelectPhotoBlock) {
self.didSelectPhotoBlock(YES); self.didSelectPhotoBlock(YES);
self.selectImageView.image = self.photoDefImage; self.selectImageView.image = self.photoDefImage;
} }
} }
}
[self hideProgressView]; [self hideProgressView];
} progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) { } progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
if (self.model.isSelected) { if (self.model.isSelected) {
...@@ -196,6 +192,17 @@ ...@@ -196,6 +192,17 @@
[self cancelBigImageRequest]; [self cancelBigImageRequest];
} }
}]; }];
if (_model.type == TZAssetCellTypeVideo) {
[[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
self->_model.iCloudFailed = YES;
if (self->_didSelectPhotoBlock) {
self->_didSelectPhotoBlock(YES);
self->_selectImageView.image = self.photoDefImage;
}
});
}];
}
} }
- (void)cancelBigImageRequest { - (void)cancelBigImageRequest {
......
...@@ -566,15 +566,11 @@ static CGFloat itemMargin = 5; ...@@ -566,15 +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.type == TZAssetModelMediaTypeLivePhoto ||
strongCell.model.type == TZAssetModelMediaTypePhotoGif ||
strongCell.model.type == TZAssetModelMediaTypeVideo) {
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) {
......
...@@ -228,9 +228,6 @@ ...@@ -228,9 +228,6 @@
_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 (self.model.type == TZAssetModelMediaTypeVideo ||
self.model.type ==TZAssetModelMediaTypePhotoGif ||
self.model.type == TZAssetModelMediaTypeLivePhoto) {
if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) { if (!photo && [info[PHImageResultIsInCloudKey] boolValue]) {
self->_icloudErrorLB.hidden = NO; self->_icloudErrorLB.hidden = NO;
self->_icloudErrorIcon.hidden = NO; self->_icloudErrorIcon.hidden = NO;
...@@ -241,7 +238,6 @@ ...@@ -241,7 +238,6 @@
if (self.iCloudSyncFailed) { if (self.iCloudSyncFailed) {
self.iCloudSyncFailed(asset, !self->_icloudErrorLB.hidden); self.iCloudSyncFailed(asset, !self->_icloudErrorLB.hidden);
} }
}
if (![asset isEqual:self->_asset]) return; if (![asset isEqual:self->_asset]) return;
if (photo) { if (photo) {
self.imageView.image = photo; self.imageView.image = photo;
...@@ -471,6 +467,16 @@ ...@@ -471,6 +467,16 @@
}]; }];
[[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]) {
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);
}
[self configPlayerWithItem:playerItem]; [self configPlayerWithItem:playerItem];
}); });
}]; }];
......
...@@ -462,6 +462,7 @@ ...@@ -462,6 +462,7 @@
TZVideoPreviewCell *currentCell = (TZVideoPreviewCell *)cell; TZVideoPreviewCell *currentCell = (TZVideoPreviewCell *)cell;
currentCell.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) { currentCell.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed; model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model]; [weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
}; };
} else if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypePhotoGif && _tzImagePickerVc.allowPickingGif) { } else if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypePhotoGif && _tzImagePickerVc.allowPickingGif) {
...@@ -469,6 +470,7 @@ ...@@ -469,6 +470,7 @@
TZGifPreviewCell *currentCell = (TZGifPreviewCell *)cell; TZGifPreviewCell *currentCell = (TZGifPreviewCell *)cell;
currentCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) { currentCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed; model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model]; [weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
}; };
} else { } else {
...@@ -497,6 +499,7 @@ ...@@ -497,6 +499,7 @@
}]; }];
photoPreviewCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) { photoPreviewCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
model.iCloudFailed = isSyncFailed; model.iCloudFailed = isSyncFailed;
[weakSelf refreshiCloudFailed:model];
[weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model]; [weakSelf.models replaceObjectAtIndex:indexPath.item withObject:model];
}; };
} }
...@@ -578,11 +581,7 @@ ...@@ -578,11 +581,7 @@
_doneButton.hidden = YES; _doneButton.hidden = YES;
} }
// iCLoud同步失败的UI刷新 // iCLoud同步失败的UI刷新
if (model.type == TZAssetModelMediaTypePhotoGif ||
model.type == TZAssetModelMediaTypeLivePhoto ||
model.type == TZAssetModelMediaTypeVideo) {
[self refreshiCloudFailed:model]; [self refreshiCloudFailed:model];
}
if (_tzImagePickerVc.photoPreviewPageDidRefreshStateBlock) { if (_tzImagePickerVc.photoPreviewPageDidRefreshStateBlock) {
_tzImagePickerVc.photoPreviewPageDidRefreshStateBlock(_collectionView, _naviBar, _backButton, _selectButton, _indexLabel, _toolBar, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel); _tzImagePickerVc.photoPreviewPageDidRefreshStateBlock(_collectionView, _naviBar, _backButton, _selectButton, _indexLabel, _toolBar, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel);
} }
...@@ -599,57 +598,22 @@ ...@@ -599,57 +598,22 @@
} }
- (void)refreshiCloudFailed:(TZAssetModel *)model{ - (void)refreshiCloudFailed:(TZAssetModel *)model{
dispatch_async(dispatch_get_main_queue(), ^{
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (model.iCloudFailed) { // onlyReturnAsset为NO时,依赖TZ返回大图,所以需要有iCloud同步失败的提示,并且不能选择,
_selectButton.hidden = YES; if (_tzImagePickerVc.onlyReturnAsset) {
_originalPhotoButton.hidden = YES; return;
_originalPhotoLabel.hidden = YES;
if (_tzImagePickerVc.selectedModels.count <= 0) {
_doneButton.enabled = !model.iCloudFailed;
}else{
_doneButton.enabled = YES;
}
}else{
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.currentIndex inSection:0];
UICollectionViewCell *cell = [_collectionView cellForItemAtIndexPath:indexPath];
if ([cell isKindOfClass:[TZPhotoPreviewCell class]]) {
TZPhotoPreviewCell *currentCell = (TZPhotoPreviewCell *)cell;
currentCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
if ([asset isEqual:model.asset]) {
if (_tzImagePickerVc.selectedModels.count <= 0) {
self->_doneButton.enabled = !isSyncFailed;
} else {
self->_doneButton.enabled = YES;
}
self->_selectButton.hidden = isSyncFailed;
}
};
} else if([cell isKindOfClass:[TZVideoPreviewCell class]]){
TZVideoPreviewCell *currentCell = (TZVideoPreviewCell *)cell;
currentCell.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
if ([asset isEqual:model.asset]) {
if (_tzImagePickerVc.selectedModels.count <= 0) {
self->_doneButton.enabled = !isSyncFailed;
} else {
self->_doneButton.enabled = YES;
}
self->_selectButton.hidden = isSyncFailed;
} }
}; TZAssetModel *currentModel = self.models[self.currentIndex];
} else if ([cell isKindOfClass:[TZGifPreviewCell class]]){
TZGifPreviewCell *currentCell = (TZGifPreviewCell *)cell;
currentCell.previewView.iCloudSyncFailed = ^(id asset, BOOL isSyncFailed) {
if ([asset isEqual:model.asset]) {
if (_tzImagePickerVc.selectedModels.count <= 0) { if (_tzImagePickerVc.selectedModels.count <= 0) {
self->_doneButton.enabled = !isSyncFailed; self->_doneButton.enabled = !currentModel.iCloudFailed;
} else { } else {
self->_doneButton.enabled = YES; self->_doneButton.enabled = YES;
} }
self->_selectButton.hidden = isSyncFailed; self->_selectButton.hidden = currentModel.iCloudFailed;
} self->_originalPhotoButton.hidden = currentModel.iCloudFailed;
}; self->_originalPhotoLabel.hidden = currentModel.iCloudFailed;
} });
}
} }
- (void)showPhotoBytes { - (void)showPhotoBytes {
......
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