Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void _showCamera(
- int rotation,
- int cameraW,
- int cameraH,
- int left,
- int top,
- int right,
- int bottom,
- String overlayBody,
- final CallbackContext callbackContext
- ){
- if(this.isShowing)return;
- isShowing = true;
- MyCustomContext mainActivity = (MyCustomContext)cordova.getActivity();
- this.cameraView.overlayWebView.stopLoading();
- cameraView.overlayWebView.loadData("", "text/html", "UTF-8");
- this.cameraView.overlayWebView.loadDataWithBaseURL("file:///android_asset/www/",overlayBody, "text/html", "UTF-8","");
- this.camera = Camera.open();
- Camera.Parameters parameters = this.camera.getParameters();
- if(parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)){
- parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
- }
- parameters.setPreviewSize(cameraW,cameraH);
- getBiggestPictureSize(parameters);
- parameters.setPictureFormat(ImageFormat.JPEG);
- parameters.setJpegQuality(90);
- this.camera.setParameters(parameters);
- this.parameters = parameters;
- this.camera.setDisplayOrientation(rotation);
- mainActivity.mainView.addView(this.cameraView); // cameraView is the GroupView
- this.cameraView.measure(right - left, bottom - top);
- this.cameraView.layout(left, top, right, bottom);
- this.cameraView.setCamera(camera);
- this._autoFocus();
- callbackContext.success();
- }
- protected void _hideCamera(){
- isShowing = false;
- if(camera == null)return;
- cameraView.overlayWebView.loadData("", "text/html", "UTF-8");
- this.cameraView.setCamera(null);
- this.camera.stopPreview();
- this.camera.release();
- this.camera = null;
- MyCustomContext mainActivity = (MyCustomContext)cordova.getActivity();
- mainActivity.mainView.removeView(this.cameraView);
- }
- @Override
- public void onDestroy(){
- if(this.camera != null){
- this.cameraView.setCamera(null);
- this.camera.stopPreview();
- this.camera.release();
- this.camera = null;
- }
- }
- @Override
- public void onPause(boolean multitasking){
- if(this.camera != null){
- this.cameraView.setCamera(null);
- this.camera.stopPreview();
- this.camera.release();
- this.camera = null;
- }
- }
- @Override
- public void onResume(boolean multitasking){
- if(this.isShowing){
- this.camera = Camera.open(0);
- this.camera.setParameters(this.parameters);
- this.cameraView.setCamera(this.camera);
- this._autoFocus();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment