Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed ISSUE #99 When in ELCAssetTablePicker, make screenshots, the de… #125

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions Classes/ELCImagePicker/ELCAlbumPickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#import "ELCAssetSelectionDelegate.h"
#import "ELCAssetPickerFilterDelegate.h"



@interface ELCAlbumPickerController : UITableViewController <ELCAssetSelectionDelegate>

@property (nonatomic, weak) id<ELCAssetSelectionDelegate> parent;
Expand Down
298 changes: 237 additions & 61 deletions Classes/ELCImagePicker/ELCAlbumPickerController.m

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Classes/ELCImagePicker/ELCAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

@interface ELCAsset : NSObject

@property (nonatomic, strong) ALAsset *asset;
@property (nonatomic, strong) NSObject *asset;
@property (nonatomic, weak) id<ELCAssetDelegate> parent;
@property (nonatomic, assign) BOOL selected;
@property (nonatomic,assign) int index;

- (id)initWithAsset:(ALAsset *)asset;
- (id)initWithAsset:(NSObject *)asset;
- (NSComparisonResult)compareWithIndex:(ELCAsset *)_ass;
@end
2 changes: 1 addition & 1 deletion Classes/ELCImagePicker/ELCAsset.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (NSString *)description
return [NSString stringWithFormat:@"ELCAsset index:%d",self.index];
}

- (id)initWithAsset:(ALAsset*)asset
- (id)initWithAsset:(NSObject*)asset
{
self = [super init];
if (self) {
Expand Down
98 changes: 77 additions & 21 deletions Classes/ELCImagePicker/ELCAssetCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#import "ELCAsset.h"
#import "ELCConsole.h"
#import "ELCOverlayImageView.h"
#import "ELCConstants.h"
#import <Photos/Photos.h>

@interface ELCAssetCell ()

@property (nonatomic, strong) NSArray *rowAssets;
@property (nonatomic, strong) NSMutableArray *imageViewArray;
@property (nonatomic, strong) NSMutableArray *overlayViewArray;
@property (strong) PHCachingImageManager *imageManager;

@end

Expand All @@ -36,6 +39,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
self.overlayViewArray = overlayArray;

self.alignmentLeft = YES;
self.imageManager = [[PHCachingImageManager alloc] init];
}
return self;
}
Expand All @@ -50,32 +54,84 @@ - (void)setAssets:(NSArray *)assets
[view removeFromSuperview];
}
//set up a pointer here so we don't keep calling [UIImage imageNamed:] if creating overlays
UIImage *overlayImage = nil;
for (int i = 0; i < [_rowAssets count]; ++i) {

if(!IS_IOS8){
UIImage *overlayImage = nil;
for (int i = 0; i < [_rowAssets count]; ++i) {

ELCAsset *asset = [_rowAssets objectAtIndex:i];

ELCAsset *asset = [_rowAssets objectAtIndex:i];
if (i < [_imageViewArray count]) {
UIImageView *imageView = [_imageViewArray objectAtIndex:i];
imageView.image = [UIImage imageWithCGImage:((ALAsset*)asset.asset).thumbnail];
} else {
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:((ALAsset*)asset.asset).thumbnail]];
[_imageViewArray addObject:imageView];
}

if (i < [_overlayViewArray count]) {
ELCOverlayImageView *overlayView = [_overlayViewArray objectAtIndex:i];
overlayView.hidden = asset.selected ? NO : YES;
overlayView.labIndex.text = [NSString stringWithFormat:@"%d", asset.index + 1];
} else {
if (overlayImage == nil) {
overlayImage = [UIImage imageNamed:@"Overlay.png"];
}
ELCOverlayImageView *overlayView = [[ELCOverlayImageView alloc] initWithImage:overlayImage];
[_overlayViewArray addObject:overlayView];
overlayView.hidden = asset.selected ? NO : YES;
overlayView.labIndex.text = [NSString stringWithFormat:@"%d", asset.index + 1];
}

if (i < [_imageViewArray count]) {
UIImageView *imageView = [_imageViewArray objectAtIndex:i];
imageView.image = [UIImage imageWithCGImage:asset.asset.thumbnail];
} else {
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:asset.asset.thumbnail]];
[_imageViewArray addObject:imageView];
}

if (i < [_overlayViewArray count]) {
ELCOverlayImageView *overlayView = [_overlayViewArray objectAtIndex:i];
overlayView.hidden = asset.selected ? NO : YES;
overlayView.labIndex.text = [NSString stringWithFormat:@"%d", asset.index + 1];
} else {
if (overlayImage == nil) {
overlayImage = [UIImage imageNamed:@"Overlay.png"];
} else {

UIImage *overlayImage = nil;
for (int i = 0; i < [_rowAssets count]; ++i) {

ELCAsset *asset = [_rowAssets objectAtIndex:i];

PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];

// Download from cloud if necessary
// Need to make NO for existing images.
options.networkAccessAllowed = YES;
options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {

};

if (i < [_imageViewArray count]) {
UIImageView *imageView = [_imageViewArray objectAtIndex:i];
PHAsset *phAsset = (PHAsset *)asset.asset;
[self.imageManager requestImageForAsset:phAsset targetSize:CGSizeMake(70, 70) contentMode:PHImageContentModeAspectFill options:options resultHandler:^(UIImage * result, NSDictionary * info) {
imageView.image = result;
}];

} else {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)];
PHAsset *phAsset = (PHAsset *)asset.asset;
[self.imageManager requestImageForAsset:phAsset targetSize:CGSizeMake(70, 70) contentMode:PHImageContentModeAspectFill options:options resultHandler:^(UIImage * result, NSDictionary * info) {
imageView.image = result;
}];

[_imageViewArray addObject:imageView];
}

if (i < [_overlayViewArray count]) {
ELCOverlayImageView *overlayView = [_overlayViewArray objectAtIndex:i];
overlayView.hidden = asset.selected ? NO : YES;
overlayView.labIndex.text = [NSString stringWithFormat:@"%d", asset.index + 1];
} else {
if (overlayImage == nil) {
overlayImage = [UIImage imageNamed:@"Overlay.png"];
}
ELCOverlayImageView *overlayView = [[ELCOverlayImageView alloc] initWithImage:overlayImage];
[_overlayViewArray addObject:overlayView];
overlayView.hidden = asset.selected ? NO : YES;
overlayView.labIndex.text = [NSString stringWithFormat:@"%d", asset.index + 1];
}
ELCOverlayImageView *overlayView = [[ELCOverlayImageView alloc] initWithImage:overlayImage];
[_overlayViewArray addObject:overlayView];
overlayView.hidden = asset.selected ? NO : YES;
overlayView.labIndex.text = [NSString stringWithFormat:@"%d", asset.index + 1];
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/ELCImagePicker/ELCAssetTablePicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@interface ELCAssetTablePicker : UITableViewController <ELCAssetDelegate>

@property (nonatomic, weak) id <ELCAssetSelectionDelegate> parent;
@property (nonatomic, strong) ALAssetsGroup *assetGroup;
@property (nonatomic, strong) NSObject *assetGroup;
@property (nonatomic, strong) NSMutableArray *elcAssets;
@property (nonatomic, strong) IBOutlet UILabel *selectedAssetsLabel;
@property (nonatomic, assign) BOOL singleSelection;
Expand Down
Loading