From d60521f06f75ca9a453bac4bc7e3c26516e266f6 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 27 Dec 2009 17:20:56 +0000 Subject: [PATCH] further push down our "is this message for us" logic. --- src/com/fsck/k9/activity/MessageList.java | 98 +++++++++-------------- 1 file changed, 37 insertions(+), 61 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 5c459cdc4..0e2af271a 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -1574,19 +1574,10 @@ public class MessageList @Override public void synchronizeMailboxAddOrUpdateMessage(Account account, String folder, Message message) { - if (updateForMe(account, folder)) - { - FolderInfoHolder f = mCurrentFolder; - // XXX TODO, this is the wrong folder - if (f != null) - { - addOrUpdateMessage(account, f, message); - } - } - - return; + addOrUpdateMessage(account, folder, message); } + @Override public void synchronizeMailboxRemovedMessage(Account account, String folder,Message message) { @@ -1644,33 +1635,13 @@ public class MessageList @Override public void listLocalMessagesAddMessages(Account account, String folder, List messages) { - if (updateForMe(account, folder)) - { - FolderInfoHolder f = mCurrentFolder; - - // xxx "f"? - if (f != null) - { - addOrUpdateMessages(account, mCurrentFolder, messages); - } - } - - + addOrUpdateMessages(account, folder, messages); } @Override public void listLocalMessagesUpdateMessage(Account account, String folder, Message message) { - if (updateForMe(account, folder)) - { - FolderInfoHolder f = mCurrentFolder; - // XXX TODO, this is the wrong folder - if (f != null) - { - addOrUpdateMessage(account, f, message); - } - } - + addOrUpdateMessage(account, folder, message); } @Override public void folderStatusChanged(Account account, String folder, int unreadMessageCount) @@ -1683,19 +1654,6 @@ public class MessageList } - private boolean updateForMe(Account account, String folder) - { - if (mQueryString != null || (account.equals(mAccount) && mFolderName != null && folder.equals(mFolderName))) - { - return true; - } - else - { - return false; - } - } - - public void pendingCommandsProcessing(Account account) { @@ -1720,6 +1678,19 @@ public class MessageList }; + + + private boolean updateForMe(Account account, String folder) + { + if (mQueryString != null || (account.equals(mAccount) && mFolderName != null && folder.equals(mFolderName))) + { + return true; + } + else + { + return false; + } + } private Drawable mAttachmentIcon; private Drawable mAnsweredIcon; private View footerView = null; @@ -1747,40 +1718,45 @@ public class MessageList removeMessages(messages); } - private void addOrUpdateMessage(Account account, FolderInfoHolder folder, Message message) + private void addOrUpdateMessage(Account account, String folder, Message message) { List messages = new ArrayList(); messages.add(message); addOrUpdateMessages(account, folder, messages); + } - private void addOrUpdateMessages(Account account, FolderInfoHolder folder, List messages) + private void addOrUpdateMessages(Account account, String folder, List messages) { boolean needsSort = false; List messagesToAdd = new ArrayList(); List messagesToRemove = new ArrayList(); + FolderInfoHolder f = mCurrentFolder; // This is wrong, but what the old code did. for (Message message : messages) { - MessageInfoHolder m = getMessage(message.getUid()); + if (updateForMe(account, folder)) + { + MessageInfoHolder m = getMessage(message.getUid()); - if (m == null) - { - m = new MessageInfoHolder(message, folder, account); - messagesToAdd.add(m); - } - else - { - if (message.isSet(Flag.DELETED)) + if (m == null) { - messagesToRemove.add(m); - + m = new MessageInfoHolder(message, f, account); + messagesToAdd.add(m); } else { - m.populate(message, folder, account); - needsSort = true; + if (message.isSet(Flag.DELETED)) + { + messagesToRemove.add(m); + } + else + { + m.populate(message, f, account); + needsSort = true; + + } } } }