9
0
mirror of https://gitee.com/shuto/customCamera.git synced 2026-02-16 00:00:09 +08:00

Mise au propre du code (commentaires, suppression d'espaces ...)

This commit is contained in:
Thomas Boy
2014-11-14 17:32:41 +01:00
parent a674443551
commit a896c2cd66
3 changed files with 30 additions and 60 deletions

View File

@@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-16
target=Google Inc.:Google APIs:14

View File

@@ -15,17 +15,15 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
public CameraPreview(Context context, Camera camera) {
super(context);
mCamera = camera;
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
/******************************/
/** WHEN THE VIEW IS CREATED **/
/******************************/
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, now tell the camera where to draw the preview.
try {
mCamera.setPreviewCallback(null);
mCamera.setPreviewDisplay(holder);
@@ -36,51 +34,36 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
Log.d("error", "Error setting camera preview: " + e.getMessage());
}
}
/******************************/
/** WHEN THE VIEW IS CHANGED **/
/******************************/
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
System.out.println("surfaceChanged");
// If your preview can change or rotate, take care of those events here.
// Make sure to stop the preview before resizing or reformatting it.
if (mHolder.getSurface() == null){
// preview surface does not exist
return;
}
//
// stop preview before making changes
try {
System.out.println("SHIT");
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
//
// // set preview size and make any resize, rotate or
// // reformatting changes here
//
// start preview with new settings
} catch (Exception e){}
try {
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e){
Log.d("error", "Error starting camera preview: " + e.getMessage());
}
}
/********************************************/
/** POUR DETRUIRE LA SURFACE DE LA PREVIEW **/
/********************************************/
/*******************************************/
/** TO DESTROY THE SURFACE OF THE PREVIEW **/
/*******************************************/
public void surfaceDestroyed(SurfaceHolder holder) {
System.out.println("SURFACE DESTROYED");
if(mCamera!=null){
System.out.println("surfaceDestroyed -> LA CAMERA N'EST PAS NULLE");
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
// mCamera.release();
mCamera = null;
System.out.println("surfaceDestroy -> DESTRUCTION TERMINEE ");
}
}
}
}

View File

@@ -32,11 +32,6 @@ public class CameraView extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
System.out.println("ON RENTRE DANS L'APPLICATION");
super.onCreate(savedInstanceState);
/* Remove title bar */
@@ -165,9 +160,9 @@ public class CameraView extends Activity {
return true;
}
/******************/
/** GERE LE ZOOM **/
/******************/
/*********************/
/** MANAGE THE ZOOM **/
/*********************/
private void handleZoom(MotionEvent event, Camera.Parameters params, float mDist) {
int maxZoom = params.getMaxZoom();
int zoom = params.getZoom();
@@ -187,9 +182,9 @@ public class CameraView extends Activity {
mCamera.setParameters(params);
}
/*******************/
/** GERE LE FOCUS **/
/*******************/
/**********************/
/** MANAGE THE FOCUS **/
/**********************/
public void handleFocus(MotionEvent event, Camera.Parameters params) {
List<String> supportedFocusModes = params.getSupportedFocusModes();
if (supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
@@ -201,7 +196,7 @@ public class CameraView extends Activity {
}
/*******************************************************/
/** DETERMINE L'ESPACE ENTRE LES DEUX PREMIERS DOIGTS **/
/** DETERMINE THE SPACE BETWEEN THE FIRST TWO FINGERS **/
/*******************************************************/
private float getFingerSpacing(MotionEvent event) {
float x = event.getX(0) - event.getX(1);
@@ -210,7 +205,7 @@ public class CameraView extends Activity {
}
/***************************/
/** AFFICHER LA MINIATURE **/
/** DISPLAY THE MINIATURE **/
/***************************/
public void showMiniature(View view){
ImageView imageView = (ImageView) findViewById(R.id.normal);
@@ -218,10 +213,8 @@ public class CameraView extends Activity {
if(modeMiniature == 0){
FrameLayout.LayoutParams paramsMiniature = new FrameLayout.LayoutParams(imageView.getWidth()/4, imageView.getHeight()/4);
paramsMiniature.gravity=Gravity.BOTTOM;
imageView.setAlpha(imageView.getAlpha());
imageView.setAlpha(imageView.getAlpha());
modeMiniature = 1;
imageView.setLayoutParams(paramsMiniature);
@@ -245,27 +238,21 @@ public class CameraView extends Activity {
}
}
/****************************************************/
/** METHODE POUR DETRUIRE LA VUE (ICI, l'ACTIVITE) **/
/****************************************************/
/*****************************************************/
/** METHOD TO DESTROY THE VIEW (HERE, THE ACTIVITY) **/
/*****************************************************/
protected void onDestroy(){
System.out.println("onDestroy -> JE DETRUIS LA VUE ! ");
super.onDestroy();
if(mCamera!=null){
System.out.println("onDestroy -> LA CAMERA N'EST PAS NULL ");
mCamera.stopPreview();
mCamera = null;
System.out.println("onDestroy -> DESTRUCTION TERMINEE ");
}
}
/********************************************************/
/** METHODE POUR METTRE LA NOUVELLE VUE APRES ROTATION **/
/********************************************************/
/*************************************************/
/** METHOD TO APPLY THE NEW VIEW AFTER ROTATION **/
/*************************************************/
protected void onResume(){
System.out.println("onResume -> JE REMET LA VUE ! ");
super.onResume();
// mPreview.getHolder().removeCallback(mPreview);
System.out.println("onResume -> test ");
}
}