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
This commit is contained in:
Makoto Onuki 2011-02-01 15:37:20 -08:00
parent db0a601714
commit d4df1cf65a

View File

@ -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());
}