Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nek023 committed Apr 5, 2015
1 parent 7475228 commit 8971bdf
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 31 deletions.
4 changes: 2 additions & 2 deletions QBImagePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@
AAF1CA3A1ACE765F005F6295 /* QBFooterView.m */,
AABBF08E1ACEDDFF003188A3 /* QBCheckmarkView.h */,
AABBF08F1ACEDDFF003188A3 /* QBCheckmarkView.m */,
AA3AD0711ACFA06700BF523E /* QBVideoIndicatorView.h */,
AA3AD0721ACFA06700BF523E /* QBVideoIndicatorView.m */,
AA3AD06D1ACF9A3A00BF523E /* QBVideoIconView.h */,
AA3AD06E1ACF9A3A00BF523E /* QBVideoIconView.m */,
AA3AD0711ACFA06700BF523E /* QBVideoIndicatorView.h */,
AA3AD0721ACFA06700BF523E /* QBVideoIndicatorView.m */,
);
name = Views;
sourceTree = "<group>";
Expand Down
41 changes: 19 additions & 22 deletions QBImagePicker/QBAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ - (void)setAssetCollection:(PHAssetCollection *)assetCollection
{
_assetCollection = assetCollection;

// Set title
self.navigationItem.title = self.assetCollection.localizedTitle;

[self updateFetchRequest];
[self.collectionView reloadData];
}
Expand Down Expand Up @@ -534,13 +531,13 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtInde
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
QBImagePickerController *imagePickerController = self.imagePickerController;
NSMutableOrderedSet *selectedAssets = imagePickerController.selectedAssets;

// Add asset to set
PHAsset *asset = self.fetchResult[indexPath.item];
[selectedAssets addObject:asset];

if (imagePickerController.allowsMultipleSelection) {
// Add asset to set
NSMutableOrderedSet *selectedAssets = imagePickerController.selectedAssets;
[selectedAssets addObject:asset];

[self updateControlState];

if (imagePickerController.showsNumberOfSelectedAssets) {
Expand All @@ -551,38 +548,38 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
[self.navigationController setToolbarHidden:NO animated:YES];
}
}
} else {
if ([imagePickerController.delegate respondsToSelector:@selector(qb_imagePickerController:didFinishPickingAssets:)]) {
[imagePickerController.delegate qb_imagePickerController:imagePickerController didFinishPickingAssets:@[asset]];
}
}

if ([imagePickerController.delegate respondsToSelector:@selector(qb_imagePickerController:didSelectAsset:)]) {
[imagePickerController.delegate qb_imagePickerController:imagePickerController didSelectAsset:asset];
}

if (!imagePickerController.allowsMultipleSelection) {
if ([imagePickerController.delegate respondsToSelector:@selector(qb_imagePickerController:didFinishPickingAssets:)]) {
[imagePickerController.delegate qb_imagePickerController:imagePickerController didFinishPickingAssets:@[asset]];
}
}
}

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.imagePickerController.allowsMultipleSelection) {
return;
}

QBImagePickerController *imagePickerController = self.imagePickerController;
NSMutableOrderedSet *selectedAssets = imagePickerController.selectedAssets;

// Remove asset from set
PHAsset *asset = self.fetchResult[indexPath.item];
[selectedAssets removeObject:asset];

if (imagePickerController.allowsMultipleSelection) {
[self updateControlState];
[self updateControlState];

if (imagePickerController.showsNumberOfSelectedAssets) {
[self updateSelectionInfo];

if (imagePickerController.showsNumberOfSelectedAssets) {
[self updateSelectionInfo];

if (selectedAssets.count == 0) {
// Hide toolbar
[self.navigationController setToolbarHidden:YES animated:YES];
}
if (selectedAssets.count == 0) {
// Hide toolbar
[self.navigationController setToolbarHidden:YES animated:YES];
}
}

Expand Down
3 changes: 1 addition & 2 deletions QBImagePicker/QBImagePicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
// Copyright (c) 2015 Katsuma Tanaka. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
#import <Foundation/Foundation.h>

//! Project version number for QBImagePicker.
FOUNDATION_EXPORT double QBImagePickerVersionNumber;
Expand Down
2 changes: 1 addition & 1 deletion QBImagePicker/QBImagePickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//

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

@class QBImagePickerController;
@class PHAsset;

@protocol QBImagePickerControllerDelegate <NSObject>

Expand Down
2 changes: 1 addition & 1 deletion QBImagePicker/QBVideoIconView.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// QBImagePicker
//
// Created by Katsuma Tanaka on 2015/04/04.
// Copyright (c) 2015年 Katsuma Tanaka. All rights reserved.
// Copyright (c) 2015 Katsuma Tanaka. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion QBImagePicker/QBVideoIconView.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// QBImagePicker
//
// Created by Katsuma Tanaka on 2015/04/04.
// Copyright (c) 2015年 Katsuma Tanaka. All rights reserved.
// Copyright (c) 2015 Katsuma Tanaka. All rights reserved.
//

#import "QBVideoIconView.h"
Expand Down
2 changes: 1 addition & 1 deletion QBImagePicker/QBVideoIndicatorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// QBImagePicker
//
// Created by Katsuma Tanaka on 2015/04/04.
// Copyright (c) 2015年 Katsuma Tanaka. All rights reserved.
// Copyright (c) 2015 Katsuma Tanaka. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion QBImagePicker/QBVideoIndicatorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// QBImagePicker
//
// Created by Katsuma Tanaka on 2015/04/04.
// Copyright (c) 2015年 Katsuma Tanaka. All rights reserved.
// Copyright (c) 2015 Katsuma Tanaka. All rights reserved.
//

#import "QBVideoIndicatorView.h"
Expand Down

0 comments on commit 8971bdf

Please sign in to comment.