Commit 74749fcc authored by Andrey Pavlenko's avatar Andrey Pavlenko

fix for #1724: making Java samples compatible with Android 3.1+ targets

parent cff117c0
......@@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
return mFrameHeight;
}
public void setPreview() throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mCamera.setPreviewTexture( new SurfaceTexture(10) );
else
mCamera.setPreviewDisplay(null);
}
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
Log.i(TAG, "surfaceCreated");
if (mCamera != null) {
......@@ -61,15 +68,11 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
params.setPreviewSize(getFrameWidth(), getFrameHeight());
mCamera.setParameters(params);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mCamera.setPreviewTexture( new SurfaceTexture(10) );
} else {
try {
mCamera.setPreviewDisplay(null);
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
}
}
try {
setPreview();
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
}
mCamera.startPreview();
}
}
......
......@@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
return mFrameHeight;
}
public void setPreview() throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mCamera.setPreviewTexture( new SurfaceTexture(10) );
else
mCamera.setPreviewDisplay(null);
}
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
Log.i(TAG, "surfaceCreated");
if (mCamera != null) {
......@@ -61,15 +68,11 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
params.setPreviewSize(getFrameWidth(), getFrameHeight());
mCamera.setParameters(params);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mCamera.setPreviewTexture( new SurfaceTexture(10) );
} else {
try {
mCamera.setPreviewDisplay(null);
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
}
}
try {
setPreview();
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
}
mCamera.startPreview();
}
}
......
......@@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
return mFrameHeight;
}
public void setPreview() throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mCamera.setPreviewTexture( new SurfaceTexture(10) );
else
mCamera.setPreviewDisplay(null);
}
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
Log.i(TAG, "surfaceCreated");
if (mCamera != null) {
......@@ -61,15 +68,11 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
params.setPreviewSize(getFrameWidth(), getFrameHeight());
mCamera.setParameters(params);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mCamera.setPreviewTexture( new SurfaceTexture(10) );
} else {
try {
mCamera.setPreviewDisplay(null);
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
}
}
try {
setPreview();
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
}
mCamera.startPreview();
}
}
......
......@@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
return mFrameHeight;
}
public void setPreview() throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mCamera.setPreviewTexture( new SurfaceTexture(10) );
else
mCamera.setPreviewDisplay(null);
}
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
Log.i(TAG, "surfaceCreated");
if (mCamera != null) {
......@@ -61,15 +68,11 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
params.setPreviewSize(getFrameWidth(), getFrameHeight());
mCamera.setParameters(params);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mCamera.setPreviewTexture( new SurfaceTexture(10) );
} else {
try {
mCamera.setPreviewDisplay(null);
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
}
}
try {
setPreview();
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
}
mCamera.startPreview();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment