diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/SyncDatabaseListener.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/SyncDatabaseListener.java index dbe3f30f2..701d00bc0 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/SyncDatabaseListener.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/SyncDatabaseListener.java @@ -2,13 +2,13 @@ package com.todoroo.astrid.actfm.sync; import java.util.List; +import com.todoroo.andlib.data.AbstractModel; import com.todoroo.andlib.data.DatabaseDao.ModelUpdateListener; import com.todoroo.astrid.actfm.sync.ActFmSyncThread.ModelType; import com.todoroo.astrid.actfm.sync.messages.ChangesHappened; import com.todoroo.astrid.actfm.sync.messages.ClientToServerMessage; -import com.todoroo.astrid.data.RemoteModel; -public class SyncDatabaseListener implements ModelUpdateListener { +public class SyncDatabaseListener implements ModelUpdateListener { private final List> queue; private final Object monitor; @@ -23,9 +23,11 @@ public class SyncDatabaseListener implements ModelUpd @Override public void onModelUpdated(MTYPE model) { ChangesHappened ch = ChangesHappened.instantiateChangesHappened(model.getId(), modelType); - queue.add(ch); - synchronized(monitor) { - monitor.notifyAll(); + if (!queue.contains(ch)) { + queue.add(ch); + synchronized(monitor) { + monitor.notifyAll(); + } } } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ClientToServerMessage.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ClientToServerMessage.java index a6931bec0..c1a3eca39 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ClientToServerMessage.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ClientToServerMessage.java @@ -78,6 +78,37 @@ public abstract class ClientToServerMessage { } } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((table == null) ? 0 : table.hashCode()); + result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ClientToServerMessage other = (ClientToServerMessage) obj; + if (table == null) { + if (other.table != null) + return false; + } else if (!table.equals(other.table)) + return false; + if (uuid == null) { + if (other.uuid != null) + return false; + } else if (!uuid.equals(other.uuid)) + return false; + return true; + } + protected abstract boolean serializeExtrasToJSON(JSONObject serializeTo) throws JSONException; protected abstract String getTypeString(); }