From b0de9913e0a50126de090f00da84474db88200a6 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 8 Oct 2010 06:18:30 +0000 Subject: [PATCH] more correct list updates after restore --- src/com/fsck/k9/activity/MessageList.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index c2e7ff34c..022a23a69 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -368,6 +369,7 @@ public class MessageList index = Collections.binarySearch(mAdapter.messages, message, getComparator()); } + Log.v(K9.LOG_TAG," Index was "+index + "For "+message.subject); if (index < 0) { index = (index * -1) - 1; @@ -770,12 +772,18 @@ public class MessageList sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE); mController.addListener(mAdapter.mListener); - mAdapter.messages.clear(); mAdapter.markAllMessagesAsDirty(); if (mFolderName != null) { - mController.listLocalMessagesSynchronous(mAccount, mFolderName, mAdapter.mListener); + if (mAdapter.messages.isEmpty()) + { + mController.listLocalMessages(mAccount, mFolderName, mAdapter.mListener); + } + else + { + mController.listLocalMessagesSynchronous(mAccount, mFolderName, mAdapter.mListener); + } mController.notifyAccountCancel(this, mAccount); MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount); @@ -2252,11 +2260,13 @@ public class MessageList } public void pruneDirtyMessages() { - for (MessageInfoHolder holder : mAdapter.messages) + Iterator iter = mAdapter.messages.iterator(); + while (iter.hasNext()) { + MessageInfoHolder holder = iter.next(); if (holder.dirty) { - removeMessage(holder); + iter.remove(); } } } @@ -2342,6 +2352,7 @@ public class MessageList } else { + m.dirty = false; // as we reload the message, unset its dirty flag messageHelper.populate(m, message, new FolderInfoHolder(MessageList.this, messageFolder, account), account); needsSort = true; }