Commit b6964b93 authored by Ruslan Balkarov's avatar Ruslan Balkarov

IsCameraRoll to model

parent e07490f1
...@@ -43,4 +43,7 @@ typedef enum : NSUInteger { ...@@ -43,4 +43,7 @@ typedef enum : NSUInteger {
@property (nonatomic, strong) NSArray *models; @property (nonatomic, strong) NSArray *models;
@property (nonatomic, strong) NSArray *selectedModels; @property (nonatomic, strong) NSArray *selectedModels;
@property (nonatomic, assign) NSUInteger selectedCount; @property (nonatomic, assign) NSUInteger selectedCount;
@property (nonatomic, assign) BOOL isCameraRoll;
@end @end
...@@ -138,7 +138,7 @@ static dispatch_once_t onceToken; ...@@ -138,7 +138,7 @@ static dispatch_once_t onceToken;
if (![collection isKindOfClass:[PHAssetCollection class]]) continue; if (![collection isKindOfClass:[PHAssetCollection class]]) continue;
if ([self isCameraRollAlbum:collection]) { if ([self isCameraRollAlbum:collection]) {
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option]; PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
model = [self modelWithResult:fetchResult name:collection.localizedTitle]; model = [self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES];
if (completion) completion(model); if (completion) completion(model);
break; break;
} }
...@@ -148,7 +148,7 @@ static dispatch_once_t onceToken; ...@@ -148,7 +148,7 @@ static dispatch_once_t onceToken;
if ([group numberOfAssets] < 1) return; if ([group numberOfAssets] < 1) return;
if ([self isCameraRollAlbum:group]) { if ([self isCameraRollAlbum:group]) {
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName]; NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
model = [self modelWithResult:group name:name]; model = [self modelWithResult:group name:name isCameraRoll:YES];
if (completion) completion(model); if (completion) completion(model);
*stop = YES; *stop = YES;
} }
...@@ -190,9 +190,9 @@ static dispatch_once_t onceToken; ...@@ -190,9 +190,9 @@ static dispatch_once_t onceToken;
if ([collection.localizedTitle tz_containsString:@"Hidden"] || [collection.localizedTitle isEqualToString:@"已隐藏"]) continue; if ([collection.localizedTitle tz_containsString:@"Hidden"] || [collection.localizedTitle isEqualToString:@"已隐藏"]) continue;
if ([collection.localizedTitle tz_containsString:@"Deleted"] || [collection.localizedTitle isEqualToString:@"最近删除"]) continue; if ([collection.localizedTitle tz_containsString:@"Deleted"] || [collection.localizedTitle isEqualToString:@"最近删除"]) continue;
if ([self isCameraRollAlbum:collection]) { if ([self isCameraRollAlbum:collection]) {
[albumArr insertObject:[self modelWithResult:fetchResult name:collection.localizedTitle] atIndex:0]; [albumArr insertObject:[self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES] atIndex:0];
} else { } else {
[albumArr addObject:[self modelWithResult:fetchResult name:collection.localizedTitle]]; [albumArr addObject:[self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:NO]];
} }
} }
} }
...@@ -212,15 +212,15 @@ static dispatch_once_t onceToken; ...@@ -212,15 +212,15 @@ static dispatch_once_t onceToken;
} }
if ([self isCameraRollAlbum:group]) { if ([self isCameraRollAlbum:group]) {
[albumArr insertObject:[self modelWithResult:group name:name] atIndex:0]; [albumArr insertObject:[self modelWithResult:group name:name isCameraRoll:YES] atIndex:0];
} else if ([name isEqualToString:@"My Photo Stream"] || [name isEqualToString:@"我的照片流"]) { } else if ([name isEqualToString:@"My Photo Stream"] || [name isEqualToString:@"我的照片流"]) {
if (albumArr.count) { if (albumArr.count) {
[albumArr insertObject:[self modelWithResult:group name:name] atIndex:1]; [albumArr insertObject:[self modelWithResult:group name:name isCameraRoll:NO] atIndex:1];
} else { } else {
[albumArr addObject:[self modelWithResult:group name:name]]; [albumArr addObject:[self modelWithResult:group name:name isCameraRoll:NO]];
} }
} else { } else {
[albumArr addObject:[self modelWithResult:group name:name]]; [albumArr addObject:[self modelWithResult:group name:name isCameraRoll:NO]];
} }
} failureBlock:nil]; } failureBlock:nil];
} }
...@@ -843,10 +843,11 @@ static dispatch_once_t onceToken; ...@@ -843,10 +843,11 @@ static dispatch_once_t onceToken;
#pragma mark - Private Method #pragma mark - Private Method
- (TZAlbumModel *)modelWithResult:(id)result name:(NSString *)name{ - (TZAlbumModel *)modelWithResult:(id)result name:(NSString *)name isCameraRoll:(BOOL)isCameraRoll {
TZAlbumModel *model = [[TZAlbumModel alloc] init]; TZAlbumModel *model = [[TZAlbumModel alloc] init];
model.result = result; model.result = result;
model.name = name; model.name = name;
model.isCameraRoll = isCameraRoll;
if ([result isKindOfClass:[PHFetchResult class]]) { if ([result isKindOfClass:[PHFetchResult class]]) {
PHFetchResult *fetchResult = (PHFetchResult *)result; PHFetchResult *fetchResult = (PHFetchResult *)result;
model.count = fetchResult.count; model.count = fetchResult.count;
......
...@@ -84,7 +84,7 @@ static CGFloat itemMargin = 5; ...@@ -84,7 +84,7 @@ static CGFloat itemMargin = 5;
tzImagePickerVc.navLeftBarButtonSettingBlock(leftButton); tzImagePickerVc.navLeftBarButtonSettingBlock(leftButton);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
} }
_showTakePhotoBtn = (([[TZImageManager manager] isCameraRollAlbum:_model.name]) && tzImagePickerVc.allowTakePicture); _showTakePhotoBtn = (_model.isCameraRoll && tzImagePickerVc.allowTakePicture);
// [self resetCachedAssets]; // [self resetCachedAssets];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment