From b47b6b2108edea3dd3b74578496cc15fa91bd18d Mon Sep 17 00:00:00 2001 From: Christophe BOUCAUT Date: Wed, 10 Jun 2015 16:17:47 +0200 Subject: [PATCH] Add the cameraIsStarted method at plugin --- www/customCamera.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/www/customCamera.js b/www/customCamera.js index 92137fb..c5b4516 100644 --- a/www/customCamera.js +++ b/www/customCamera.js @@ -4,6 +4,8 @@ // Get cordova plugin. var exec = require("cordova/exec"); + var cameraIsStarted = false; + // constructor. function CustomCameraExport() {} @@ -41,13 +43,20 @@ } function successFctCallback(data) { - successFct(data); + cameraIsStarted = false; + if (successFct instanceof Function) { + successFct(data); + } } function failFctCallback(data) { - failFct(data.code, data.message); + cameraIsStarted = false; + if (failFct instanceof Function) { + failFct(data.code, data.message); + } } + cameraIsStarted = true; exec( successFctCallback, failFctCallback, @@ -70,5 +79,14 @@ ); }; + /** + * Check if the camera is started or not. + * + * @return {boolean} True: It's started, else false. + */ + CustomCameraExport.prototype.cameraIsStarted = function() { + return cameraIsStarted; + }; + module.exports = new CustomCameraExport(); })(require, module); \ No newline at end of file