Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)selectedAssets:(NSArray*)_assets {
- // leoparro fix - if there's no selected assets go back to rootvc
- if ([_assets count] == 0 && [[[Global sharedInstance] cacheSelectedImgArray] count] == 0) {
- [self popToRootViewControllerAnimated:YES];
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
- return;
- }
- else if ([_assets count] == 0 && [[[Global sharedInstance] cacheSelectedImgArray] count] > 0) {
- [self popToRootViewControllerAnimated:NO];
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
- if([delegate respondsToSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:)]) {
- [delegate performSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:) withObject:self withObject:nil];
- }
- }
- else {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Preparing Photos\nPlease Wait..."
- message:nil
- delegate:self
- cancelButtonTitle:nil
- otherButtonTitles: nil];
- UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- // Adjust the indicator so it is up a few pixels from the bottom of the alert
- indicator.center = CGPointMake((alert.bounds.size.width/2) + 140, alert.bounds.size.height + 85);
- [indicator startAnimating];
- [alert addSubview:indicator];
- [indicator release];
- [alert performSelectorInBackground:@selector(show) withObject:nil];
- NSMutableArray *returnArray = [[NSMutableArray alloc] init];
- if (self.returnArray) {
- [returnArray release];
- self.returnArray = nil;
- }
- self.returnArray = [[NSMutableArray alloc] init];
- [_assets enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- ALAsset *asset = (ALAsset *)obj;
- NSString *sFilename = [[asset defaultRepresentation] filename];
- if (![[Global sharedInstance] checkExistImage:sFilename]) {
- NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];
- [workingDictionary setObject:sFilename forKey:@"filename"];
- // ALAssetRepresentation *rep = [asset defaultRepresentation];
- // CGImageRef imgRef = [[asset defaultRepresentation] fullScreenImage];
- // DLog(@"rep: %@", rep);
- // CGImageRef imgRef = [rep fullScreenImage];
- // DLog(@"imgRef: %@", imgRef);
- UIImage *tmpImage = [[UIImage alloc] initWithCGImage:[[asset defaultRepresentation] fullScreenImage]];
- DLog(@"tmpImage: %@", tmpImage);
- NSData *jpegData = UIImageJPEGRepresentation(tmpImage, 0.5);
- NSString *sImgFilePath = [[Global sharedInstance] cachedPathForFileName:sFilename];
- DLog(@"imgPath: %@", sImgFilePath);
- BOOL bWriteSuccess = [jpegData writeToFile:sImgFilePath atomically:YES];
- if (!bWriteSuccess) {
- ALog(@"Error writing file - %@", sImgFilePath);
- }
- else {
- [returnArray addObject:sFilename]; // add image filename to array
- }
- [tmpImage release];
- [workingDictionary release];
- if (*stop == YES) {
- DLog(@"true");
- }
- }
- else {
- DLog(@"Image already exists! Filename: %@", sFilename);
- }
- }];
- // save to cached selected images array
- if ([self.returnArray count] > 0) {
- [[[Global sharedInstance] cacheSelectedImgArray] addObjectsFromArray:self.returnArray];
- }
- [alert dismissWithClickedButtonIndex:0 animated:YES];
- [alert release];
- [self popToRootViewControllerAnimated:NO];
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
- if([delegate respondsToSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:)]) {
- [delegate performSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:) withObject:self withObject:nil];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment