From d4df1cf65aea6df33fa17680457c28abd73bd543 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Tue, 1 Feb 2011 15:37:20 -0800 Subject: [PATCH] Don't mix up loader managers - Don't use activity's LoaderManager in fragments. Fragments have their own loader managers, and using the wrong one causes loaders won't get reset() when the owner fragment gets destroyed(). - Don't destroy loaders by ourselves. The combination of these two issues caused the problem where the loader callbacks wouldn't get the reset event, which resulted in the adapter holding a closed cursor. Bug 3412079 Change-Id: Ib7441565ea69adb08eb74845b0996c7b8ae6f53b --- src/com/android/email/activity/MoveMessageToDialog.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/activity/MoveMessageToDialog.java b/src/com/android/email/activity/MoveMessageToDialog.java index 5a6c0677b..dbdf2b4b6 100644 --- a/src/com/android/email/activity/MoveMessageToDialog.java +++ b/src/com/android/email/activity/MoveMessageToDialog.java @@ -96,9 +96,6 @@ public class MoveMessageToDialog extends DialogFragment implements DialogInterfa @Override public void onDestroy() { - LoaderManager lm = getActivity().getLoaderManager(); - lm.destroyLoader(ActivityHelper.GLOBAL_LOADER_ID_MOVE_TO_DIALOG_MESSAGE_CHECKER); - lm.destroyLoader(ActivityHelper.GLOBAL_LOADER_ID_MOVE_TO_DIALOG_MAILBOX_LOADER); mDestroyed = true; super.onDestroy(); } @@ -117,7 +114,7 @@ public class MoveMessageToDialog extends DialogFragment implements DialogInterfa new MailboxesAdapter.EmptyCallback()); builder.setSingleChoiceItems(mAdapter, -1, this); - activity.getLoaderManager().initLoader( + getLoaderManager().initLoader( ActivityHelper.GLOBAL_LOADER_ID_MOVE_TO_DIALOG_MESSAGE_CHECKER, null, new MessageCheckerCallback()); @@ -178,7 +175,7 @@ public class MoveMessageToDialog extends DialogFragment implements DialogInterfa return; } mAccountId = accountId; - getActivity().getLoaderManager().initLoader( + getLoaderManager().initLoader( ActivityHelper.GLOBAL_LOADER_ID_MOVE_TO_DIALOG_MAILBOX_LOADER, null, new MailboxesLoaderCallbacks()); }