summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2010-05-13 16:21:29 +0800
committerOwen Lin <owenlin@google.com>2010-05-14 15:34:45 +0800
commitc8e13fecea56e679418f41ba454f867c49f888aa (patch)
tree34de90f2ed953091f836d998f8fc0dee82cafdbd /src
parentc4e6d563c3ae57e237952b82ad20ee693dfbf9d1 (diff)
downloadLegacyCamera-c8e13fecea56e679418f41ba454f867c49f888aa.zip
LegacyCamera-c8e13fecea56e679418f41ba454f867c49f888aa.tar.gz
LegacyCamera-c8e13fecea56e679418f41ba454f867c49f888aa.tar.bz2
Initialize the HeadUpDisplay only once in the life time of the activity.
And review the code so that mHeadUpDisplay won't be null when used. Change-Id: I335a25e64035627c30ec2c6f45c17566f0ea2420
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java27
-rw-r--r--src/com/android/camera/VideoCamera.java20
2 files changed, 25 insertions, 22 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 0b33728..052d16c 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -314,9 +314,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
if (!mIsImageCaptureIntent) {
setOrientationIndicator(mLastOrientation);
}
- if (mGLRootView != null) {
- mHeadUpDisplay.setOrientation(mLastOrientation);
- }
+ mHeadUpDisplay.setOrientation(mLastOrientation);
}
}
};
@@ -358,6 +356,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
installIntentFilter();
initializeFocusTone();
initializeZoom();
+ initializeHeadUpDisplay();
mFirstTimeInitialized = true;
changeHeadUpDisplayState();
addIdleHandler();
@@ -456,7 +455,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
// Perform zoom only when preview is started and snapshot is not in
// progress.
if (mPausing || !isCameraIdle() || !mPreviewing
- || mHeadUpDisplay == null || mZoomState != ZOOM_STOPPED) {
+ || mZoomState != ZOOM_STOPPED) {
return false;
}
@@ -970,9 +969,9 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
Configuration config = getResources().getConfiguration();
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE
&& !mPausing && mFirstTimeInitialized) {
- if (mGLRootView == null) initializeHeadUpDisplay();
+ if (mGLRootView == null) attachHeadUpDisplay();
} else if (mGLRootView != null) {
- finalizeHeadUpDisplay();
+ detachHeadUpDisplay();
}
}
@@ -996,17 +995,15 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
}
private void initializeHeadUpDisplay() {
- FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
- mGLRootView = new GLRootView(this);
- frame.addView(mGLRootView);
-
mHeadUpDisplay = new CameraHeadUpDisplay(this);
CameraSettings settings = new CameraSettings(this, mInitialParams);
mHeadUpDisplay.initialize(this,
settings.getPreferenceGroup(R.xml.camera_preferences));
mHeadUpDisplay.setListener(new MyHeadUpDisplayListener());
- mHeadUpDisplay.setOrientation(mLastOrientation);
+ }
+ private void attachHeadUpDisplay() {
+ mHeadUpDisplay.setOrientation(mLastOrientation);
if (mParameters.isZoomSupported()) {
mHeadUpDisplay.setZoomRatios(getZoomRatios());
mHeadUpDisplay.setZoomIndex(mZoomValue);
@@ -1017,13 +1014,15 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
}
});
}
+ FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
+ mGLRootView = new GLRootView(this);
+ mGLRootView.setContentPane(mHeadUpDisplay);
+ frame.addView(mGLRootView);
updateSceneModeInHud();
-
- mGLRootView.setContentPane(mHeadUpDisplay);
}
- private void finalizeHeadUpDisplay() {
+ private void detachHeadUpDisplay() {
mHeadUpDisplay.setGpsHasSignal(false);
mHeadUpDisplay.collapse();
((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView);
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 0e04e31..958f19e 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -346,6 +346,8 @@ public class VideoCamera extends NoSearchActivity
mShutterButton.setOnShutterButtonListener(this);
mShutterButton.requestFocus();
+ initializeHeadUpDisplay();
+
// Make sure preview is started.
try {
startPreviewThread.join();
@@ -367,17 +369,13 @@ public class VideoCamera extends NoSearchActivity
Configuration config = getResources().getConfiguration();
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE
&& !mPausing && mGLRootView == null) {
- initializeHeadUpDisplay();
+ attachHeadUpDisplay();
} else if (mGLRootView != null) {
- finalizeHeadUpDisplay();
+ detachHeadUpDisplay();
}
}
private void initializeHeadUpDisplay() {
- FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
- mGLRootView = new GLRootView(this);
- frame.addView(mGLRootView);
-
mHeadUpDisplay = new CamcorderHeadUpDisplay(this);
CameraSettings settings = new CameraSettings(this, mParameters);
@@ -387,11 +385,17 @@ public class VideoCamera extends NoSearchActivity
group = filterPreferenceScreenByIntent(group);
}
mHeadUpDisplay.initialize(this, group);
- mGLRootView.setContentPane(mHeadUpDisplay);
mHeadUpDisplay.setListener(new MyHeadUpDisplayListener());
}
- private void finalizeHeadUpDisplay() {
+ private void attachHeadUpDisplay() {
+ FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
+ mGLRootView = new GLRootView(this);
+ frame.addView(mGLRootView);
+ mGLRootView.setContentPane(mHeadUpDisplay);
+ }
+
+ private void detachHeadUpDisplay() {
mHeadUpDisplay.collapse();
((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView);
mGLRootView = null;