updated camera & console

This commit is contained in:
Stanimir Karoserov
2014-05-21 19:05:34 +03:00
parent db987a361d
commit 826050eda0
4 changed files with 10 additions and 5 deletions

View File

@ -36,8 +36,7 @@ function topViewControllerWithRootViewController(rootViewController: any) {
export var takePicture = function (options?: types.Options): promises.Promise<imageSource.ImageSource> { export var takePicture = function (options?: types.Options): promises.Promise<imageSource.ImageSource> {
var d = promises.defer<imageSource.ImageSource>(); var d = promises.defer<imageSource.ImageSource>();
// FIXME: this is done to prevent listener from being freed by JS garbage collector // This is done to prevent listener from being freed by JS garbage collector
// we will try to fix this at JS Bridge level
var listener; var listener;
var ImagePickerControllerListener = Foundation.NSObject.extends({ var ImagePickerControllerListener = Foundation.NSObject.extends({
@ -49,7 +48,6 @@ export var takePicture = function (options?: types.Options): promises.Promise<im
imagePickerControllerDidFinishPickingMediaWithInfo: function (picker, info) { imagePickerControllerDidFinishPickingMediaWithInfo: function (picker, info) {
console.log('takeImage received'); console.log('takeImage received');
picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null); picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null);
// FIXME: do not work with listener here
listener = null; listener = null;
var image = imageSource.fromNativeSource(info.valueForKey(UIKit.UIImagePickerControllerOriginalImage)); var image = imageSource.fromNativeSource(info.valueForKey(UIKit.UIImagePickerControllerOriginalImage));
d.resolve(image); d.resolve(image);
@ -58,7 +56,6 @@ export var takePicture = function (options?: types.Options): promises.Promise<im
imagePickerControllerDidCancel: function (picker) { imagePickerControllerDidCancel: function (picker) {
console.info('takeImage canceled'); console.info('takeImage canceled');
picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null); picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null);
// FIXME: do not work with listener here
listener = null; listener = null;
d.reject(new Error('takePicture canceled by user')); d.reject(new Error('takePicture canceled by user'));
} }

View File

@ -61,4 +61,9 @@ export declare class Console {
* @param obj The object instance to be dumped. * @param obj The object instance to be dumped.
*/ */
public dump(obj: any): void; public dump(obj: any): void;
/**
* Prints the state of the specified object to the console.
*/
public dir(obj: any): void;
} }

View File

@ -320,4 +320,6 @@ export class Console {
result.push('=== dump(): finished ==='); result.push('=== dump(): finished ===');
this.log(result.join('\n')); this.log(result.join('\n'));
} }
}
public dir = this.dump;
}

1
declarations.d.ts vendored
View File

@ -20,6 +20,7 @@ declare module i {
log(message: any, ...optionalParams: any[]): void; log(message: any, ...optionalParams: any[]): void;
trace(): void; trace(): void;
dump(obj: any): void; dump(obj: any): void;
dir(obj: any): void;
} }
} }