From 137417dade91f8a98cefa655cbd0d48b8cf52af1 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Thu, 25 Mar 2010 11:53:10 -0700 Subject: Revert "Fix one more NPE." This reverts commit 416f65b0cc009d251a16512e7b6c3621bf62dc76. This broke video recording because the GLThread has exited after the GLSurfaceView is detached from the window, so the the runnable put into queueEvent never runs. Change-Id: I7b071ef170d4d36fd551a81db9f3af7f6ff85a83 --- src/com/android/camera/Camera.java | 29 ++++++++++++++++++----------- src/com/android/camera/VideoCamera.java | 11 ++++++++--- 2 files changed, 26 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 0256e08..3296912 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -290,7 +290,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, // once only. We could have done these things in onCreate() but we want to // make preview screen appear as soon as possible. private void initializeFirstTime() { - if (mFirstTimeInitialized || mPausing || isFinishing()) return; + if (mFirstTimeInitialized) return; // Create orientation listenter. This should be done first because it // takes some time to get first orientation. @@ -308,11 +308,13 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, if (!mIsImageCaptureIntent) { setOrientationIndicator(mLastOrientation); } - mGLRootView.queueEvent(new Runnable() { - public void run() { - mHeadUpDisplay.setOrientation(mLastOrientation); - } - }); + if (mGLRootView != null) { + mGLRootView.queueEvent(new Runnable() { + public void run() { + mHeadUpDisplay.setOrientation(mLastOrientation); + } + }); + } } } }; @@ -1275,10 +1277,12 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, closeCamera(); resetScreenOn(); - mGLRootView.onPause(); - if (mHeadUpDisplay != null) { - mHeadUpDisplay.setGpsHasSignal(false); - mHeadUpDisplay.collapse(); + if (mGLRootView != null) { + mGLRootView.onPause(); + if (mHeadUpDisplay != null) { + mHeadUpDisplay.setGpsHasSignal(false); + mHeadUpDisplay.collapse(); + } } if (mFirstTimeInitialized) { mOrientationListener.disable(); @@ -2064,7 +2068,10 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, private boolean switchToVideoMode() { if (isFinishing() || !isCameraIdle()) return false; MenuHelper.gotoVideoMode(this); - ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); + if (mGLRootView != null) { + ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); + mGLRootView = null; + } finish(); return true; } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 69d7353..411386a 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -632,8 +632,10 @@ public class VideoCamera extends NoSearchActivity super.onPause(); mPausing = true; - mGLRootView.onPause(); - if (mHeadUpDisplay != null) mHeadUpDisplay.collapse(); + if (mGLRootView != null) { + mGLRootView.onPause(); + if (mHeadUpDisplay != null) mHeadUpDisplay.collapse(); + } // Hide the preview now. Otherwise, the preview may be rotated during // onPause and it is annoying to users. @@ -1397,7 +1399,10 @@ public class VideoCamera extends NoSearchActivity private boolean switchToCameraMode() { if (isFinishing() || mMediaRecorderRecording) return false; MenuHelper.gotoCameraMode(this); - ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); + if (mGLRootView != null) { + ((ViewGroup) mGLRootView.getParent()).removeView(mGLRootView); + mGLRootView = null; + } finish(); return true; } -- cgit v1.1