diff options
author | Owen Lin <owenlin@google.com> | 2012-05-04 11:46:29 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2012-05-08 18:10:33 +0800 |
commit | ec9a033559f34e5407387cb7d095aee27ddc337b (patch) | |
tree | cb7b3365217a6f93c4ab033b2a525c427bba150f /src/com/android/gallery3d | |
parent | dc0e7625d69cce4c933f927c0f9474c951abe758 (diff) | |
download | android_packages_apps_Gallery2-ec9a033559f34e5407387cb7d095aee27ddc337b.tar.gz android_packages_apps_Gallery2-ec9a033559f34e5407387cb7d095aee27ddc337b.tar.bz2 android_packages_apps_Gallery2-ec9a033559f34e5407387cb7d095aee27ddc337b.zip |
Keep the last page if finish() is rejected.
bug: 6414642
Change-Id: I480edc43608c08088177113cb3607d517c91e9f6
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r-- | src/com/android/gallery3d/app/StateManager.java | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/com/android/gallery3d/app/StateManager.java b/src/com/android/gallery3d/app/StateManager.java index 77a24d8f3..096602a78 100644 --- a/src/com/android/gallery3d/app/StateManager.java +++ b/src/com/android/gallery3d/app/StateManager.java @@ -146,6 +146,21 @@ public class StateManager { } void finishState(ActivityState state) { + // The finish() request could be rejected (only happens under Monkey), + // If it is rejected, we won't close the last page. + if (mStack.size() == 1) { + Activity activity = (Activity) mContext.getAndroidContext(); + if (mResult != null) { + activity.setResult(mResult.resultCode, mResult.resultData); + } + activity.finish(); + if (!activity.isFinishing()) { + Log.w(TAG, "finish is rejected, keep the last state"); + return; + } + Log.v(TAG, "no more state, finish activity"); + } + Log.v(TAG, "finishState " + state); if (state != mStack.peek().activityState) { if (state.isDestroyed()) { @@ -164,21 +179,7 @@ public class StateManager { mContext.getGLRoot().setContentPane(null); state.onDestroy(); - if (mStack.isEmpty()) { - Log.v(TAG, "no more state, finish activity"); - Activity activity = (Activity) mContext.getAndroidContext(); - if (mResult != null) { - activity.setResult(mResult.resultCode, mResult.resultData); - } - activity.finish(); - - // The finish() request is rejected (only happens under Monkey), - // so we start the default page instead. - if (!activity.isFinishing()) { - Log.v(TAG, "finish() failed, start default page"); - ((Gallery) mContext).startDefaultPage(); - } - } else { + if (!mStack.isEmpty()) { // Restore the immediately previous state ActivityState top = mStack.peek().activityState; if (mIsResumed) top.resume(); |