From 6e9fef5e00072acad09d7138fc992aae4bd17f90 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Tue, 13 Oct 2009 20:20:35 +0800 Subject: Fix 2150734. The problem seems to be the media player is re-created when we get window focus after onPause. We now only create media player when the activity is resumed and has focus. --- src/com/android/camera/MovieView.java | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/com/android/camera') diff --git a/src/com/android/camera/MovieView.java b/src/com/android/camera/MovieView.java index 54d3e8e..0f4df52 100644 --- a/src/com/android/camera/MovieView.java +++ b/src/com/android/camera/MovieView.java @@ -33,6 +33,9 @@ public class MovieView extends NoSearchActivity { private MovieViewControl mControl; private boolean mFinishOnCompletion; + private boolean mResumed = false; // Whether this activity has been resumed. + private boolean mFocused = false; // Whether this window has focus. + private boolean mControlResumed = false; // Whether the MovieViewControl is resumed. @Override public void onCreate(Bundle icicle) { @@ -62,15 +65,30 @@ public class MovieView extends NoSearchActivity { @Override public void onPause() { - mControl.onPause(); super.onPause(); + mResumed = false; + if (mControlResumed) { + mControl.onPause(); + mControlResumed = false; + } + } + + @Override + public void onResume() { + super.onResume(); + mResumed = true; + if (mFocused && mResumed && !mControlResumed) { + mControl.onResume(); + mControlResumed = true; + } } @Override public void onWindowFocusChanged(boolean hasFocus) { - if (hasFocus) { - Log.v(TAG, "hasFocus"); + mFocused = hasFocus; + if (mFocused && mResumed && !mControlResumed) { mControl.onResume(); + mControlResumed = true; } } } -- cgit v1.1