From 4f11b50de573ab8ce937e5c7544ec4c21bd62f1f Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Thu, 3 Sep 2009 15:27:55 +0200 Subject: [PATCH] MessageView: Bug 2097855, observer on prevNextCursor unregistered twice. --- .../android/email/activity/MessageView.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java index 1d48a69b8..681cfd183 100644 --- a/src/com/android/email/activity/MessageView.java +++ b/src/com/android/email/activity/MessageView.java @@ -366,9 +366,9 @@ public class MessageView extends Activity implements OnClickListener { if (mMessage != null) { startPresenceCheck(); - // get a new next/prev cursor, but only if we already had one + // get a new next/prev cursor, but only if mailbox is set // (otherwise it's "too soon" and other pathways will cause it to be loaded) - if (mLoadPrevNextTask == null && mPrevNextCursor != null) { + if (mLoadPrevNextTask == null && mMailboxId != -1) { mLoadPrevNextTask = new LoadPrevNextTask(mMailboxId); mLoadPrevNextTask.execute(); } @@ -379,10 +379,14 @@ public class MessageView extends Activity implements OnClickListener { public void onPause() { super.onPause(); mController.removeResultCallback(mControllerCallback); - // Manage the next/prev cursor + closePrevNextCursor(); + } + + private void closePrevNextCursor() { if (mPrevNextCursor != null) { mPrevNextCursor.unregisterContentObserver(mNextPrevObserver); - mPrevNextCursor.deactivate(); + mPrevNextCursor.close(); + mPrevNextCursor = null; } } @@ -416,12 +420,7 @@ public class MessageView extends Activity implements OnClickListener { mMessageContentView.destroy(); mMessageContentView = null; } - // Destroy the next/prev cursor if we're holding one - // Note, the observer was already unregistered in onPause() - if (mPrevNextCursor != null) { - mPrevNextCursor.close(); - mPrevNextCursor = null; - } + // the next/prev cursor was closed in onPause() } private void onDelete() { @@ -970,10 +969,7 @@ public class MessageView extends Activity implements OnClickListener { return; } // replace the older cursor if there is one - if (mPrevNextCursor != null) { - mPrevNextCursor.unregisterContentObserver(MessageView.this.mNextPrevObserver); - mPrevNextCursor.close(); - } + closePrevNextCursor(); mPrevNextCursor = cursor; mPrevNextCursor.registerContentObserver(MessageView.this.mNextPrevObserver); repositionPrevNextCursor();