From 42e0b3e04547bf887893c347466471498b88b39b Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 18 Sep 2012 04:16:01 +0200 Subject: [PATCH] Code cleanup and simplification --- src/com/fsck/k9/activity/MessageList.java | 50 +++++------------------ 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 94e9e5397..b390f9ac8 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -1,7 +1,6 @@ package com.fsck.k9.activity; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; @@ -1360,46 +1359,17 @@ public class MessageList extends K9ListActivity implements OnItemClickListener { } } - private void onToggleRead(final List holders) { - LocalMessage message; - Folder folder; - Account account; - String folderName; + private void onToggleFlag(MessageInfoHolder messageInfo) { + LocalMessage message = messageInfo.message; + Folder folder = message.getFolder(); + Account account = folder.getAccount(); + String folderName = folder.getName(); - int i = 0; - for (final Iterator iterator = holders.iterator(); iterator.hasNext(); i++) { - final MessageInfoHolder messageInfo = iterator.next(); - message = messageInfo.message; - folder = message.getFolder(); - account = folder.getAccount(); - folderName = message.getFolder().getName(); + mController.setFlag(account, folderName, new Message[] { message }, Flag.FLAGGED, + !messageInfo.flagged); - mController.setFlag(account, folderName, new Message[]{message}, Flag.SEEN, !messageInfo.read); - - messageInfo.read = !messageInfo.read; - mAdapter.sortMessages(); - } - } - - private void onToggleFlag(final List holders) { - LocalMessage message; - Folder folder; - Account account; - String folderName; - - int i = 0; - for (final Iterator iterator = holders.iterator(); iterator.hasNext(); i++) { - final MessageInfoHolder messageInfo = iterator.next(); - message = messageInfo.message; - folder = message.getFolder(); - account = folder.getAccount(); - folderName = message.getFolder().getName(); - - mController.setFlag(account, folderName, new Message[]{message}, Flag.FLAGGED, !messageInfo.flagged); - - messageInfo.flagged = !messageInfo.flagged; - mAdapter.sortMessages(); - } + messageInfo.flagged = !messageInfo.flagged; + mAdapter.sortMessages(); computeBatchDirection(); } @@ -1973,7 +1943,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener { public void onClick(View v) { // Perform action on clicks MessageInfoHolder message = (MessageInfoHolder) getItem((Integer)v.getTag()); - onToggleFlag(Arrays.asList(new MessageInfoHolder[]{message})); + onToggleFlag(message); } };