diff --git a/src/com/fsck/k9/MessagingController.java b/src/com/fsck/k9/MessagingController.java index a1226ac47..b7cb30425 100644 --- a/src/com/fsck/k9/MessagingController.java +++ b/src/com/fsck/k9/MessagingController.java @@ -1508,20 +1508,21 @@ public class MessagingController implements Runnable boolean messageChanged = syncFlags(localMessage, remoteMessage); if (messageChanged) { - if (isMessageSuppressed(account, folder, localMessage) == false) - { - for (MessagingListener l : getListeners()) - { - l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); - } - } - if (localMessage.isSet(Flag.DELETED)) + if (localMessage.isSet(Flag.DELETED) || isMessageSuppressed(account, folder, localMessage)) { for (MessagingListener l : getListeners()) { l.synchronizeMailboxRemovedMessage(account, folder, localMessage); } } + else + { + for (MessagingListener l : getListeners()) + { + l.synchronizeMailboxAddOrUpdateMessage(account, folder, localMessage); + } + } + } progress.incrementAndGet(); for (MessagingListener l : getListeners()) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index ef8c08d52..6fdafa9cb 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -143,20 +143,22 @@ public class MessageList public void removeMessage(final List messages) { - runOnUiThread(new Runnable() { public void run() { for (MessageInfoHolder message : messages) { - if (mFolderName == null || (message.folder != null && message.folder.name.equals(mFolderName))) + if (message != null) { - if (message != null && message.selected && mSelectedCount > 0) + if (mFolderName == null || (message.folder != null && message.folder.name.equals(mFolderName))) { - mSelectedCount--; + if (message.selected && mSelectedCount > 0) + { + mSelectedCount--; + } + mAdapter.messages.remove(message); } - mAdapter.messages.remove(message); } } mAdapter.notifyDataSetChanged(); @@ -1627,7 +1629,15 @@ public class MessageList @Override public void synchronizeMailboxRemovedMessage(Account account, String folder,Message message) { - removeMessage(getMessage(message.getUid())); + MessageInfoHolder holder = getMessage(message.getUid()); + if (holder == null) + { + Log.w(K9.LOG_TAG, "Got callback to remove non-existent message with UID " + message.getUid()); + } + else + { + removeMessage(holder); + } } @Override @@ -1791,32 +1801,28 @@ public class MessageList 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) { if (updateForMe(account, folder)) { MessageInfoHolder m = getMessage(message.getUid()); - - if (m == null) + if (message.isSet(Flag.DELETED)) + { + if (m != null) + { + messagesToRemove.add(m); + } + } + else if (m == null) { m = new MessageInfoHolder(message, account); messagesToAdd.add(m); } else { - if (message.isSet(Flag.DELETED)) - { - messagesToRemove.add(m); - - } - else - { - m.populate(message, new FolderInfoHolder(message.getFolder(), account), account); - needsSort = true; - - } + m.populate(message, new FolderInfoHolder(message.getFolder(), account), account); + needsSort = true; } } }