From cbfbe1db2d9cae835ae1cf64f92057998c574c66 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Fri, 15 Jul 2011 14:49:26 -0700 Subject: [PATCH] Toggle selection on list item on long press Bug: 5020642 Change-Id: I31498122a4fe41cc81e5dbad5550a5e6620924c4 --- .../email/activity/MessageListFragment.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java index 67ebe3b9d..87224cc5c 100644 --- a/src/com/android/email/activity/MessageListFragment.java +++ b/src/com/android/email/activity/MessageListFragment.java @@ -704,8 +704,17 @@ public class MessageListFragment extends ListFragment @Override public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { if (view != mListFooterView) { + // Always toggle the item. + MessageListItem listItem = (MessageListItem) view; + boolean toggled = false; + if (!mListAdapter.isSelected(listItem)) { + toggleSelection(listItem); + toggled = true; + } + + // Additionally, check to see if we can drag the item. if (!mCallback.onDragStarted()) { - return false; // D&D not allowed. + return toggled; // D&D not allowed. } // We can't move from combined accounts view // We also need to check the actual mailbox to see if we can move items from it @@ -715,10 +724,6 @@ public class MessageListFragment extends ListFragment } else if (mailboxId > 0 && !Mailbox.canMoveFrom(mActivity, mailboxId)) { return false; } - MessageListItem listItem = (MessageListItem)view; - if (!mListAdapter.isSelected(listItem)) { - toggleSelection(listItem); - } // Start drag&drop. // Create ClipData with the Uri of the message we're long clicking @@ -747,6 +752,7 @@ public class MessageListFragment extends ListFragment } private void toggleSelection(MessageListItem itemView) { + itemView.invalidate(); mListAdapter.toggleSelected(itemView); }