1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Experimental deletedUids list in FolderInfoHolder to avoid race

conditions when using instance delete
This commit is contained in:
Daniel Applebaum 2009-01-08 04:42:56 +00:00
parent 2b01f96e4e
commit 7954b02da6

View File

@ -5,6 +5,8 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import android.app.ExpandableListActivity; import android.app.ExpandableListActivity;
import android.app.NotificationManager; import android.app.NotificationManager;
@ -1223,6 +1225,10 @@ public class FolderMessageList extends ExpandableListActivity
{ {
return; return;
} }
FolderInfoHolder holder = getFolder(folder);
if (holder != null) {
holder.deletedUids.clear();
}
mHandler.progress(false); mHandler.progress(false);
mHandler.folderLoading(folder, false); mHandler.folderLoading(folder, false);
// mHandler.folderStatus(folder, null); // mHandler.folderStatus(folder, null);
@ -1239,6 +1245,8 @@ public class FolderMessageList extends ExpandableListActivity
{ {
return; return;
} }
mHandler.progress(false); mHandler.progress(false);
mHandler.folderLoading(folder, false); mHandler.folderLoading(folder, false);
@ -1249,6 +1257,7 @@ public class FolderMessageList extends ExpandableListActivity
if (holder != null) if (holder != null)
{ {
holder.lastChecked = 0; holder.lastChecked = 0;
holder.deletedUids.clear();
} }
mHandler.folderSyncing(null); mHandler.folderSyncing(null);
} }
@ -1368,6 +1377,9 @@ public class FolderMessageList extends ExpandableListActivity
{ {
return; return;
} }
if (f.deletedUids.contains(messageUid) == false) {
f.deletedUids.add(messageUid);
}
mHandler.removeMessage(f, m); mHandler.removeMessage(f, m);
} }
@ -1389,6 +1401,9 @@ public class FolderMessageList extends ExpandableListActivity
private void addOrUpdateMessage(FolderInfoHolder folder, Message message, private void addOrUpdateMessage(FolderInfoHolder folder, Message message,
boolean sort, boolean notify) boolean sort, boolean notify)
{ {
if (folder.deletedUids.remove(message.getUid())){
return;
}
MessageInfoHolder m = getMessage(folder, message.getUid()); MessageInfoHolder m = getMessage(folder, message.getUid());
if (m == null) if (m == null)
{ {
@ -1739,6 +1754,7 @@ public class FolderMessageList extends ExpandableListActivity
public boolean lastCheckFailed; public boolean lastCheckFailed;
public List<String> deletedUids = Collections.synchronizedList(new ArrayList<String>());
/** /**
* Outbox is handled differently from any other folder. * Outbox is handled differently from any other folder.
*/ */