Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ura14h committed Jun 5, 2015
0 parents commit 46b2750
Show file tree
Hide file tree
Showing 168 changed files with 24,205 additions and 0 deletions.
1,079 changes: 1,079 additions & 0 deletions PlayOPC.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions PlayOPC/ALAssetsLibrary+CustomAlbum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ALAssetsLibrary+CustomAlbum.h
// PlayOPC
//
// Created by Hiroki Ishiura on 2015/05/06.
// Copyright (c) 2015 Hiroki Ishiura. All rights reserved.
//
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//

#import <AssetsLibrary/AssetsLibrary.h>

@interface ALAssetsLibrary (CustomAlbum)

/// 写真アルバムのカスタムグループに画像データを書き込みます。
- (void)writeImageDataToSavedPhotosAlbum:(NSData *)imageData metadata:(NSDictionary *)metadata groupName:(NSString *)groupName completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock;

@end
84 changes: 84 additions & 0 deletions PlayOPC/ALAssetsLibrary+CustomAlbum.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// ALAssetsLibrary+CustomAlbum.m
// PlayOPC
//
// Created by Hiroki Ishiura on 2015/05/06.
// Copyright (c) 2015 Hiroki Ishiura. All rights reserved.
//
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//

#import "ALAssetsLibrary+CustomAlbum.h"

@implementation ALAssetsLibrary (CustomAlbum)

- (void)writeImageDataToSavedPhotosAlbum:(NSData *)imageData metadata:(NSDictionary *)metadata groupName:(NSString *)groupName completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock {
DEBUG_LOG(@"imageData.length=%ld, metadata=%@, group=%@", (long)imageData.length, metadata, groupName);

// 写真グループに画像を保存します。
// !!!: weakなselfを使うとenumerateGroupsWithTypes:usingBlock:failureBlock:より内側の処理に到達する前に解放されてしまいます。
__block ALAssetsLibrary *weakSelf = self;
[weakSelf writeImageDataToSavedPhotosAlbum:imageData metadata:metadata completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
if (completionBlock) {
completionBlock(assetURL, error);
}
weakSelf = nil;
return;
}
DEBUG_LOG(@"The image is saved into photos alubm.");
__block BOOL foundGroup = NO;
[weakSelf enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group && [[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:groupName]) {
// 写真アルバムにカスタムグループが見つかった場合はそのグループに保存した画像を登録します。
DEBUG_LOG(@"Update the exsisted album: groupName=%@", groupName);
foundGroup = YES;
[weakSelf assetForURL:assetURL resultBlock:^(ALAsset *asset) {
[group addAsset:asset];
if (completionBlock) {
completionBlock(assetURL, nil);
}
weakSelf = nil;
} failureBlock:^(NSError *error) {
if (completionBlock) {
completionBlock(assetURL, error);
}
weakSelf = nil;
}];
return;
}
if (!group && !foundGroup) {
// 写真アルバムにカスタムグループが見つからなかった場合はグループを新規作成して画像を登録します。
DEBUG_LOG(@"Create the new album: groupName=%@", groupName);
[weakSelf addAssetsGroupAlbumWithName:groupName resultBlock:^(ALAssetsGroup *group) {
[weakSelf assetForURL:assetURL resultBlock:^(ALAsset *asset) {
[group addAsset:asset];
if (completionBlock) {
completionBlock(assetURL, nil);
}
weakSelf = nil;
} failureBlock:^(NSError *error) {
if (completionBlock) {
completionBlock(assetURL, error);
}
weakSelf = nil;
}];
} failureBlock:^(NSError *error) {
if (completionBlock) {
completionBlock(assetURL, error);
}
weakSelf = nil;
}];
return;
}
} failureBlock:^(NSError *error) {
if (completionBlock) {
completionBlock(assetURL, error);
}
weakSelf = nil;
}];
}];
}

@end
23 changes: 23 additions & 0 deletions PlayOPC/APanelViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// APanelViewController.h
// PlayOPC
//
// Created by Hiroki Ishiura on 2015/04/25.
// Copyright (c) 2015 Hiroki Ishiura. All rights reserved.
//
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//

#import <UIKit/UIKit.h>

/// カメラの撮影パラメータを変更します。
/// このビューコントローラーで操作できる撮影パラメータは、オートフォーカスと自動露出に関するものです。
@interface APanelViewController : UITableViewController

/// ビューコントローラーが画面を表示して活動を開始する時に呼び出されます。
- (void)didStartActivity;
/// ビューコントローラーが画面を破棄して活動を完了する時に呼び出されます。
- (void)didFinishActivity;

@end
Loading

0 comments on commit 46b2750

Please sign in to comment.