Skip to content

Commit f8c5182

Browse files
authored
Merge pull request #152 from NativeScript/lini/fix-demo-crash
fix: demo crash when camera does not return image
2 parents 99e80e7 + f102c42 commit f8c5182

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

demo-angular/app/app.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ export class AppComponent {
2424
.then((imageAsset: any) => {
2525
this.cameraImage = imageAsset;
2626
let that = this;
27-
imageAsset.getImageAsync(function (nativeImage) {
27+
imageAsset.getImageAsync(function (nativeImage, ex) {
28+
if (ex instanceof Error) {
29+
throw ex;
30+
} else if (typeof ex === "string") {
31+
throw new Error(ex);
32+
}
33+
2834
if (imageAsset.android) {
2935
// get the current density of the screen (dpi) and divide it by the default one to get the scale
3036
that.scale = nativeImage.getDensity() / android.util.DisplayMetrics.DENSITY_DEFAULT;

demo-angular/app/package.json

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,10 @@
11
{
2-
"private": false,
3-
"nativescript": {
4-
"id": "org.nativescript.helloworldng"
5-
},
62
"name": "tns-template-hello-world-ng",
73
"main": "main.js",
84
"version": "2.3.3",
9-
"author": "Telerik <support@telerik.com>",
10-
"description": "Nativescript Angular Hello World template",
11-
"license": "BSD",
12-
"keywords": [
13-
"telerik",
14-
"mobile",
15-
"angular",
16-
"nativescript",
17-
"{N}",
18-
"tns",
19-
"appbuilder",
20-
"template"
21-
],
22-
"repository": {
23-
"type": "git",
24-
"url": "git://github.com/NativeScript/template-hello-world-ng"
25-
},
26-
"homepage": "https://github.com/NativeScript/template-hello-world-ng",
275
"android": {
286
"v8Flags": "--expose_gc",
7+
"markingMode": "none",
298
"requireModules": ["nativescript-camera"]
30-
},
31-
"dependencies": {
32-
"nativescript-angular": "1.1.0",
33-
"@angular/core": "2.1.0",
34-
"@angular/common": "2.1.0",
35-
"@angular/compiler": "2.1.0",
36-
"@angular/http": "2.1.0",
37-
"@angular/platform-browser": "2.1.0",
38-
"@angular/platform-browser-dynamic": "2.1.0",
39-
"@angular/forms": "2.1.0",
40-
"@angular/router": "3.1.0",
41-
"reflect-metadata": "~0.1.8"
42-
},
43-
"devDependencies": {
44-
"zone.js": "~0.6.21",
45-
"nativescript-dev-typescript": "^0.3.2"
469
}
4710
}

src/camera.android.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import * as typesModule from "tns-core-modules/utils/types";
22
import * as utilsModule from "tns-core-modules/utils/utils";
33
import * as applicationModule from "tns-core-modules/application/application";
4-
import * as imageSourceModule from "tns-core-modules/image-source/image-source";
54
import * as imageAssetModule from "tns-core-modules/image-asset/image-asset";
65
import * as trace from "tns-core-modules/trace/trace";
76
import * as platform from "tns-core-modules/platform/platform";
87
import * as permissions from "nativescript-permissions";
98

109
let REQUEST_IMAGE_CAPTURE = 3453;
11-
let REQUEST_REQUIRED_PERMISSIONS = 1234;
1210

1311
export let takePicture = function (options?): Promise<any> {
1412
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)