From 22bbf5f4a1c0f8fca1ae6a4e2c3544ba2750f052 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 27 Jun 2014 07:53:43 -0500 Subject: [PATCH] Use remote timestamp for GtasksList.LAST_SYNC --- .../todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java | 3 ++- .../todoroo/astrid/gtasks/sync/GtasksTaskContainer.java | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java b/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java index 8c02de43d..97f4d36f4 100644 --- a/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java +++ b/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java @@ -253,8 +253,9 @@ public class GtasksSyncV2Provider extends SyncV2Provider { container.gtaskMetadata.setValue(GtasksMetadata.PARENT_TASK, gtasksMetadataService.localIdForGtasksId(t.getParent())); container.gtaskMetadata.setValue(GtasksMetadata.LAST_SYNC, DateUtilities.now() + 1000L); write(container); + lastSyncDate = Math.max(lastSyncDate, container.getUpdateTime()); } - list.setValue(GtasksList.LAST_SYNC, DateUtilities.now()); + list.setValue(GtasksList.LAST_SYNC, lastSyncDate); storeObjectDao.persist(list); gtasksTaskListUpdater.correctOrderAndIndentForList(listId); } diff --git a/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksTaskContainer.java b/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksTaskContainer.java index 933b9546b..5eda083e3 100644 --- a/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksTaskContainer.java +++ b/astrid/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksTaskContainer.java @@ -5,6 +5,7 @@ */ package com.todoroo.astrid.gtasks.sync; +import com.google.api.client.util.DateTime; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; @@ -17,6 +18,7 @@ import java.util.ArrayList; public class GtasksTaskContainer extends SyncContainer { public Metadata gtaskMetadata; + private final long updateTime; public GtasksTaskContainer(com.google.api.services.tasks.model.Task remoteTask, String listId, Metadata metadata) { this.task = new Task(); @@ -42,6 +44,13 @@ public class GtasksTaskContainer extends SyncContainer { gtaskMetadata.setValue(GtasksMetadata.ID, remoteTask.getId()); gtaskMetadata.setValue(GtasksMetadata.LIST_ID, listId); + + DateTime updated = remoteTask.getUpdated(); + updateTime = updated == null ? 0 : updated.getValue(); + } + + public long getUpdateTime() { + return updateTime; } @Override