diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java index b992b232f..662ecba43 100644 --- a/src/com/android/email/activity/MessageList.java +++ b/src/com/android/email/activity/MessageList.java @@ -238,22 +238,6 @@ public class MessageList extends K9ListActivity { break; } - case MSG_SYNC_MESSAGES: { - FolderInfoHolder folder = (FolderInfoHolder)((Object[]) msg.obj)[0]; - Message[] messages = (Message[])((Object[]) msg.obj)[1]; - - for(MessageInfoHolder message : mAdapter.messages) { - message.dirty = true; - } - - for (Message message : messages) { - mAdapter.addOrUpdateMessage(folder, message, true, false); - mAdapter.notifyDataSetChanged(); - } - mAdapter.removeDirtyMessages(); - break; - } - case MSG_FOLDER_SYNCING: { String folderName = (String)((Object[]) msg.obj)[0]; String dispString; @@ -299,14 +283,6 @@ public class MessageList extends K9ListActivity { } } - public void synchronizeMessages(FolderInfoHolder folder, Message[] messages) { - android.os.Message msg = new android.os.Message(); - msg.what = MSG_SYNC_MESSAGES; - msg.obj = new Object[] { folder, messages }; - sendMessage(msg); - } - - public void removeMessage(MessageInfoHolder message) { android.os.Message msg = new android.os.Message(); msg.what = MSG_REMOVE_MESSAGE; @@ -1187,7 +1163,7 @@ public class MessageList extends K9ListActivity { return; } - addOrUpdateMessage(folder, message, true, true); + addOrUpdateMessage(folder, message, true); } @Override @@ -1259,7 +1235,7 @@ public class MessageList extends K9ListActivity { return; } - addOrUpdateMessage(folder, message, false, false);//true, true); + addOrUpdateMessage(folder, message, false); if (mAdapter.messages.size() % 10 == 0 ) { sortMessages(); mHandler.dataChanged(); @@ -1273,7 +1249,7 @@ public class MessageList extends K9ListActivity { return; } - addOrUpdateMessage(folder, message, false, true); + addOrUpdateMessage(folder, message, false); } }; @@ -1287,17 +1263,6 @@ public class MessageList extends K9ListActivity { mAnsweredIcon = getResources().getDrawable( R.drawable.ic_mms_answered_small); } - public void removeDirtyMessages() { - Iterator iter = messages.iterator(); - while(iter.hasNext()) { - MessageInfoHolder message = iter.next(); - if (message.dirty) { - iter.remove(); - } - } - notifyDataSetChanged(); - } - public void removeMessage(MessageInfoHolder holder) { if (holder == null) { return; @@ -1314,29 +1279,21 @@ public class MessageList extends K9ListActivity { } - public void synchronizeMessages(String folder, Message[] messages) { - FolderInfoHolder f = getFolder(folder); - - if (f == null) { - return; - } - - mHandler.synchronizeMessages(f, messages); - } - public void addOrUpdateMessage(String folder, Message message) { - addOrUpdateMessage(folder, message, true, true); + addOrUpdateMessage(folder, message, true); } - private void addOrUpdateMessage(FolderInfoHolder folder, Message message, boolean sort, boolean notify) { + private void addOrUpdateMessage(FolderInfoHolder folder, Message message, boolean sort) { MessageInfoHolder m = getMessage( message.getUid()); + boolean notify = false; if (m == null) { m = new MessageInfoHolder(message, folder); mAdapter.messages.add(m); + notify = true; } else { - m.populate(message, folder); + notify = m.populate(message, folder); } if (sort) { @@ -1348,14 +1305,14 @@ public class MessageList extends K9ListActivity { } } - private void addOrUpdateMessage(String folder, Message message, boolean sort, boolean notify) { + private void addOrUpdateMessage(String folder, Message message, boolean sort) { FolderInfoHolder f = getFolder(folder); if (f == null) { return; } - addOrUpdateMessage(f, message, sort, notify); + addOrUpdateMessage(f, message, sort); } // XXX TODO - make this not use a for loop @@ -1551,8 +1508,6 @@ public class MessageList extends K9ListActivity { public boolean read; - public boolean dirty; - public boolean answered; public boolean flagged; @@ -1573,16 +1528,18 @@ public class MessageList extends K9ListActivity { populate(m, folder); } - public void populate(Message m, FolderInfoHolder folder) { + public boolean populate(Message m, FolderInfoHolder folder) { + if (this.message!=null + && m.getInternalDate().equals(this.message.getInternalDate())) { + return false; + } + try { LocalMessage message = (LocalMessage) m; Date date = message.getSentDate(); this.compareDate = date; this.folder = folder; - this.dirty = false; - - if (Utility.isDateToday(date)) { this.date = getTimeFormat().format(date); } else { @@ -1611,10 +1568,13 @@ public class MessageList extends K9ListActivity { this.uid = message.getUid(); this.message = m; + + return true; } catch (MessagingException me) { if (Config.LOGV) { Log.v(Email.LOG_TAG, "Unable to load message info", me); } + return false; } }