Skip to content

Commit

Permalink
optimize the improvement of preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpringOx committed Nov 4, 2014
1 parent f9398f8 commit 737aef0
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 144 deletions.
20 changes: 10 additions & 10 deletions AGImagePickerController Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
545FCB1E1A04849F004F4A87 /* AGAssetsPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 545FCB1D1A04849F004F4A87 /* AGAssetsPreviewController.m */; };
545FCB1E1A04849F004F4A87 /* AGIPCPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 545FCB1D1A04849F004F4A87 /* AGIPCPreviewController.m */; };
545FCB211A04D69E004F4A87 /* AGPreviewScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 545FCB201A04D69E004F4A87 /* AGPreviewScrollView.m */; };
545FCB221A067775004F4A87 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE1E332C14ED167800F6A6A2 /* CoreGraphics.framework */; };
54628BD619FAE04E00CBDE0C /* AGImagePreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 54628BD519FAE04E00CBDE0C /* AGImagePreviewController.m */; };
Expand Down Expand Up @@ -38,8 +38,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
545FCB1C1A04849F004F4A87 /* AGAssetsPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGAssetsPreviewController.h; sourceTree = "<group>"; };
545FCB1D1A04849F004F4A87 /* AGAssetsPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AGAssetsPreviewController.m; sourceTree = "<group>"; };
545FCB1C1A04849F004F4A87 /* AGIPCPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGIPCPreviewController.h; sourceTree = "<group>"; };
545FCB1D1A04849F004F4A87 /* AGIPCPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AGIPCPreviewController.m; sourceTree = "<group>"; };
545FCB1F1A04D69E004F4A87 /* AGPreviewScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGPreviewScrollView.h; sourceTree = "<group>"; };
545FCB201A04D69E004F4A87 /* AGPreviewScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AGPreviewScrollView.m; sourceTree = "<group>"; };
54628BD419FAE04E00CBDE0C /* AGImagePreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGImagePreviewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -170,22 +170,22 @@
FEDAA95616C3089600234FF0 /* AGImagePickerController.bundle */,
FEA599C914ED1C500057FF9C /* AGImagePickerController.h */,
FEA599CA14ED1C500057FF9C /* AGImagePickerController.m */,
54628BD419FAE04E00CBDE0C /* AGImagePreviewController.h */,
54628BD519FAE04E00CBDE0C /* AGImagePreviewController.m */,
FEA599E614ED38ED0057FF9C /* AGIPCAlbumsController.h */,
FEA599E714ED38ED0057FF9C /* AGIPCAlbumsController.m */,
FE3BAF8614EE80E7001BF3EC /* AGIPCAssetsController.h */,
FE3BAF8714EE80E7001BF3EC /* AGIPCAssetsController.m */,
545FCB1C1A04849F004F4A87 /* AGAssetsPreviewController.h */,
545FCB1D1A04849F004F4A87 /* AGAssetsPreviewController.m */,
54628BD419FAE04E00CBDE0C /* AGImagePreviewController.h */,
54628BD519FAE04E00CBDE0C /* AGImagePreviewController.m */,
545FCB1F1A04D69E004F4A87 /* AGPreviewScrollView.h */,
545FCB201A04D69E004F4A87 /* AGPreviewScrollView.m */,
545FCB1C1A04849F004F4A87 /* AGIPCPreviewController.h */,
545FCB1D1A04849F004F4A87 /* AGIPCPreviewController.m */,
FECDC8FF14EDB9C30038006D /* AGIPCGridCell.h */,
FECDC90014EDB9C30038006D /* AGIPCGridCell.m */,
FECDC90314EDBB690038006D /* AGIPCGridItem.h */,
FECDC90414EDBB690038006D /* AGIPCGridItem.m */,
FE3851AD1504CF7B00A9F7F8 /* AGIPCToolbarItem.h */,
FE3851AE1504CF7B00A9F7F8 /* AGIPCToolbarItem.m */,
545FCB1F1A04D69E004F4A87 /* AGPreviewScrollView.h */,
545FCB201A04D69E004F4A87 /* AGPreviewScrollView.m */,
FE465F971590B25A00C30A1D /* ALAsset+AGIPC.h */,
FE465F981590B25A00C30A1D /* ALAsset+AGIPC.m */,
);
Expand Down Expand Up @@ -274,7 +274,7 @@
FE3851AF1504CF7B00A9F7F8 /* AGIPCToolbarItem.m in Sources */,
545FCB211A04D69E004F4A87 /* AGPreviewScrollView.m in Sources */,
FE465F991590B25A00C30A1D /* ALAsset+AGIPC.m in Sources */,
545FCB1E1A04849F004F4A87 /* AGAssetsPreviewController.m in Sources */,
545FCB1E1A04849F004F4A87 /* AGIPCPreviewController.m in Sources */,
FE4DE10416C267410075E499 /* AGImagePickerController+Helper.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
22 changes: 0 additions & 22 deletions AGImagePickerController/AGAssetsPreviewController.h

This file was deleted.

89 changes: 0 additions & 89 deletions AGImagePickerController/AGAssetsPreviewController.m

This file was deleted.

29 changes: 8 additions & 21 deletions AGImagePickerController/AGIPCAssetsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import "AGIPCToolbarItem.h"

#import "AGImagePreviewController.h"
#import "AGAssetsPreviewController.h"
#import "AGIPCPreviewController.h"

@interface AGIPCAssetsController ()
{
Expand Down Expand Up @@ -240,6 +240,9 @@ - (void)viewDidLoad

// Setup Notifications
[self registerForNotifications];

// add by springox(20141105)
[AGIPCGridItem performSelector:@selector(resetNumberOfSelections)];
}

- (void)viewDidUnload
Expand All @@ -254,8 +257,9 @@ - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

// Reset the number of selections
[AGIPCGridItem performSelector:@selector(resetNumberOfSelections)];
// modified by springox(20141105)
//// Reset the number of selections
//[AGIPCGridItem performSelector:@selector(resetNumberOfSelections)];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Expand Down Expand Up @@ -441,7 +445,6 @@ - (BOOL)agGridItemCanSelect:(AGIPCGridItem *)gridItem
for (AGIPCGridItem *item in self.assets)
if (item.selected)
item.selected = NO;

return YES;
} else {
if (self.imagePickerController.maximumNumberOfPhotosToBeSelected > 0)
Expand All @@ -454,27 +457,11 @@ - (BOOL)agGridItemCanSelect:(AGIPCGridItem *)gridItem
// add by springox(20141023)
- (void)agGridItemDidTapAction:(AGIPCGridItem *)gridItem
{
NSMutableArray *tempArr = [NSMutableArray array];
for (AGIPCGridItem *item in _assets) {
if ([item isKindOfClass:[AGIPCGridItem class]]) {
[tempArr addObject:item.asset];
}
}
AGAssetsPreviewController *preController = [[AGAssetsPreviewController alloc] initWithAssets:tempArr targetAsset:gridItem.asset];
preController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.navigationController presentViewController:preController animated:YES completion:^{
// do nothing
}];

/*
ALAsset *asset = gridItem.asset;
UIImage *image = [UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage];
AGImagePreviewController *preController = [[AGImagePreviewController alloc] initWithImage:image];
AGIPCPreviewController *preController = [[AGIPCPreviewController alloc] initWithAssets:self.assets targetAsset:gridItem];
preController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.navigationController presentViewController:preController animated:YES completion:^{
// do nothing
}];
*/
}

#pragma mark - Notifications
Expand Down
36 changes: 36 additions & 0 deletions AGImagePickerController/AGIPCPreviewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AGAssetsPreviewController.h
// AGImagePickerController Demo
//
// Created by SpringOx on 14/11/1.
// Copyright (c) 2014年 Artur Grigor. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AssetsLibrary/AssetsLibrary.h>

#import "AGImagePickerControllerDefines.h"

@class AGIPCPreviewController;
@class AGIPCGridItem;
@protocol AGAssetsPreviewControllerDelegate <NSObject>

- (BOOL)previewController:(AGIPCPreviewController *)pVC canSelectItem:(AGIPCGridItem *)gridItem;

- (void)previewController:(AGIPCPreviewController *)pVC didSelectItem:(AGIPCGridItem *)gridItem;

- (void)previewController:(AGIPCPreviewController *)pVC didDeselectItem:(AGIPCGridItem *)gridItem;

@end

@interface AGIPCPreviewController : UIViewController

@property (nonatomic, strong, readonly) AGIPCGridItem *targetAsset;

@property (nonatomic, strong, readonly) NSArray *assets;

@property (nonatomic, ag_weak) id<AGAssetsPreviewControllerDelegate, NSObject> delegate;

- (id)initWithAssets:(NSArray *)assets targetAsset:(AGIPCGridItem *)targetAsset;

@end
Loading

0 comments on commit 737aef0

Please sign in to comment.