From a007d79c3f5189463463e42693c985ecdde80ab2 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Sun, 16 Oct 2011 18:13:38 -0700 Subject: [PATCH] Fix NPE in move messages Bug: 5452020 Change-Id: Id8fca21692ad1a70a2114eaa7fec6bcecab6cab6 --- src/com/android/email/activity/MessageListFragment.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java index c203c5d2e..4a3d48727 100644 --- a/src/com/android/email/activity/MessageListFragment.java +++ b/src/com/android/email/activity/MessageListFragment.java @@ -21,6 +21,7 @@ import android.app.ListFragment; import android.app.LoaderManager; import android.content.ClipData; import android.content.ContentUris; +import android.content.Context; import android.content.Loader; import android.content.res.Configuration; import android.content.res.Resources; @@ -843,8 +844,14 @@ public class MessageListFragment extends ListFragment @Override public void onMoveToMailboxSelected(long newMailboxId, long[] messageIds) { + final Context context = getActivity(); + if (context == null) { + // Detached from activity. This callback was really delayed or a monkey was involved. + return; + } + mCallback.onAdvancingOpAccepted(Utility.toLongSet(messageIds)); - ActivityHelper.moveMessages(getActivity(), newMailboxId, messageIds); + ActivityHelper.moveMessages(context, newMailboxId, messageIds); // Move is async, so we can't refresh now. Instead, just clear the selection. onDeselectAll();