Toggle selection on list item on long press
Bug: 5020642 Change-Id: I31498122a4fe41cc81e5dbad5550a5e6620924c4
This commit is contained in:
parent
8e779e627a
commit
cbfbe1db2d
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user