summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/VideoCamera.java
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-06-16 18:29:21 +0800
committerWu-cheng Li <wuchengli@google.com>2011-06-16 18:35:04 +0800
commit84a4d3eb7c9a3e33e1898729a66671332fe81577 (patch)
tree384da7125445c7a292f85774f852fa5426cd4167 /src/com/android/camera/VideoCamera.java
parent631191d322e0ae0fb3d5369e581cd8fd787c3b04 (diff)
downloadLegacyCamera-84a4d3eb7c9a3e33e1898729a66671332fe81577.zip
LegacyCamera-84a4d3eb7c9a3e33e1898729a66671332fe81577.tar.gz
LegacyCamera-84a4d3eb7c9a3e33e1898729a66671332fe81577.tar.bz2
Code refactor.
1. Make Camera and VideoCamera more consistent. 2. Fix error dialog is not displayed if VideoCamera fails to connect to camrea. 3. Move the code from onStart to onResume. Change-Id: I7dd310718e0986c17a762ca3107924cc412f72cc
Diffstat (limited to 'src/com/android/camera/VideoCamera.java')
-rw-r--r--src/com/android/camera/VideoCamera.java50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 95afba6..d9aa4aa 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -355,14 +355,13 @@ public class VideoCamera extends ActivityBase
*/
Thread startPreviewThread = new Thread(new Runnable() {
public void run() {
- mOpenCameraFail = !openCamera();
- // In eng build, we throw the exception so that test tool
- // can detect it and report it
- if (mOpenCameraFail && "eng".equals(Build.TYPE)) {
- throw new RuntimeException("openCamera failed");
+ try {
+ openCamera();
+ readVideoPreferences();
+ startPreview();
+ } catch(CameraHardwareException e) {
+ mOpenCameraFail = true;
}
- readVideoPreferences();
- startPreview();
}
});
startPreviewThread.start();
@@ -589,14 +588,6 @@ public class VideoCamera extends ActivityBase
if (icon != null) icon.setDegree(degree);
}
- @Override
- protected void onStart() {
- super.onStart();
- if (!mIsVideoCaptureIntent) {
- mSwitcher.setSwitch(SWITCH_VIDEO);
- }
- }
-
private void startPlayVideoActivity() {
Intent intent = new Intent(Intent.ACTION_VIEW, mCurrentVideoUri);
try {
@@ -841,10 +832,15 @@ public class VideoCamera extends ActivityBase
// some time to get first orientation.
mOrientationListener.enable();
if (!mPreviewing) {
- if (!openCamera()) return;
- readVideoPreferences();
- resizeForPreviewAspectRatio();
- startPreview();
+ try {
+ openCamera();
+ readVideoPreferences();
+ resizeForPreviewAspectRatio();
+ startPreview();
+ } catch(CameraHardwareException e) {
+ showCameraErrorAndFinish();
+ return;
+ }
}
keepScreenOnAwhile();
@@ -868,9 +864,9 @@ public class VideoCamera extends ActivityBase
changeHeadUpDisplayState();
- // Update the last video thumbnail.
if (!mIsVideoCaptureIntent) {
- updateThumbnailButton();
+ updateThumbnailButton(); // Update the last video thumbnail.
+ mSwitcher.setSwitch(SWITCH_VIDEO);
}
if (mPreviewing) {
@@ -888,16 +884,20 @@ public class VideoCamera extends ActivityBase
}
}
- private boolean openCamera() {
+ private void openCamera() throws CameraHardwareException {
try {
if (mCameraDevice == null) {
mCameraDevice = CameraHolder.instance().open(mCameraId);
}
} catch (CameraHardwareException e) {
- showCameraErrorAndFinish();
- return false;
+ // In eng build, we throw the exception so that test tool
+ // can detect it and report it
+ if ("eng".equals(Build.TYPE)) {
+ throw new RuntimeException("openCamera failed", e);
+ } else {
+ throw e;
+ }
}
- return true;
}
private void startPreview() {