Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
anqqa committed Dec 14, 2016
1 parent 323666a commit a39781f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions DBCamera/Controllers/DBCameraCollectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ - (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cel
[item.itemImage setImage:nil];

if ( _items.count > 0) {
__weak DBCollectionViewCell *blockItem = item;
[[[DBLibraryManager sharedInstance] defaultAssetsLibrary] assetForURL:(NSURL *)_items[indexPath.item] resultBlock:^(ALAsset *asset) {
UIImage *image = [UIImage imageWithCGImage:[asset thumbnail]];
[blockItem.itemImage setImage:image];
} failureBlock:nil];
ALAsset *asset = _items[indexPath.item];
CGImageRef thumbnailImageRef = [asset thumbnail];
UIImage *thumbnail = [UIImage imageWithCGImage:thumbnailImageRef];

item.itemImage.image = thumbnail;
}

return item;
Expand All @@ -90,7 +90,7 @@ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollection

- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[_collectionControllerDelegate collectionView:collectionView itemURL:(NSURL *)_items[indexPath.item]];
[_collectionControllerDelegate collectionView:collectionView itemURL:(NSURL *)[[asset defaultRepresentation] url]];
}

@end
13 changes: 7 additions & 6 deletions DBCamera/Managers/DBLibraryManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ - (ALAssetsLibraryGroupsEnumerationResultsBlock) assetGroupEnumerator
__block GroupsCompletionBlock block = _groupsCompletionBlock;

ALAssetsLibraryGroupsEnumerationResultsBlock groupsEnumerator = ^(ALAssetsGroup *group, BOOL *stop){
ALAssetsFilter *onlyPhotosFilter = [ALAssetsFilter allPhotos];

[group setAssetsFilter:onlyPhotosFilter];

if ( group ) {
if ( group.numberOfAssets > 0 ) {
[weakSelf setUsedGroup:group];
Expand Down Expand Up @@ -111,12 +115,9 @@ - (ALAssetsGroupEnumerationResultsBlock) assetsEnumerator

ALAssetsGroupEnumerationResultsBlock assetsEnumerator = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if ( result ) {
if( [[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto] ) {
if ( [result defaultRepresentation] ) {
[items addObject:[[result defaultRepresentation] url]];
assetResult = result;
}
}
[items addObject:result];

assetResult = result;
} else {
*stop = YES;

Expand Down

0 comments on commit a39781f

Please sign in to comment.