Closed orangemechanic closed 9 years ago
Test done on a Galaxy SII
After narrowing down a bit, the Event is not triggered when you create then remove and re-create an instance of CameraView.
var camera_view = APP.CAM.createCameraView({
save_location: "topit",
width:APP.CORE.width,
height:APP.CORE.width * camera_ratio,
useFrontCamera: true
});
$.vwCameraLayer.add(camera_view);
function actionTakePicture(){
camera_view.snapPicture();
}
function refreshPictureSuccess(e){
alert("Image "+e.path);
$.vwCameraLayer.remove(camera_view);
}
camera_view.addEventListener("picture_taken", refreshPictureSuccess);
function actionRetakePicture(){
camera_view = APP.CAM.createCameraView({
save_location: "topit",
width:APP.CORE.width,
height:APP.CORE.width * camera_ratio,
useFrontCamera: true
});
$.vwCameraLayer.add(camera_view);
}
FALSE ALERT. I've found the stupid but logic parade to fix it.
When you re-create a new CameraView instance, you have to rebind the addEventListener.
That makes sense. When the camera_view is removed, it is deallocated from memory (or flagged for garbage collection), meaning the old event listener binding is also deallocated.
function refreshPictureSuccess(e){
alert("Image "+e.path);
}
camera_view.addEventListener("picture_taken", refreshPictureSuccess);
the Alert is never called when
camera_view.snapPicture();
is fired.in the console, it return this:
The file is correctly stored... but not returned to Titanium/App