From 288a558ebe4f67bcdee92e35eb2043533ae06e87 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Fri, 30 Mar 2012 14:36:52 -0700 Subject: [PATCH] Really minor cleanup for the awesome gtasks bug fixes --- api/src/com/todoroo/andlib/data/ContentResolverDao.java | 6 +----- .../com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java | 8 +++----- .../todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java | 4 +++- .../com/todoroo/astrid/subtasks/OrderedListUpdater.java | 5 +++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/api/src/com/todoroo/andlib/data/ContentResolverDao.java b/api/src/com/todoroo/andlib/data/ContentResolverDao.java index 5438d09df..994ad6441 100644 --- a/api/src/com/todoroo/andlib/data/ContentResolverDao.java +++ b/api/src/com/todoroo/andlib/data/ContentResolverDao.java @@ -94,17 +94,13 @@ public class ContentResolverDao { * @return true if data was written to the db, false otherwise */ public boolean save(TYPE model) { - boolean retainedTransitories = false; + writeTransitoriesToModelContentValues(model); if(model.isSaved()) { if(model.getSetValues() == null) return false; - writeTransitoriesToModelContentValues(model); - retainedTransitories = true; if(cr.update(uriWithId(model.getId()), model.getSetValues(), null, null) != 0) return true; } - if (!retainedTransitories) - writeTransitoriesToModelContentValues(model); Uri uri = cr.insert(baseUri, model.getMergedValues()); long id = Long.parseLong(uri.getLastPathSegment()); model.setId(id); diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java index aede96861..8a5b2408e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksTaskListUpdater.java @@ -24,6 +24,7 @@ import com.todoroo.astrid.data.StoreObject; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.gtasks.sync.GtasksSyncService; import com.todoroo.astrid.subtasks.OrderedListUpdater; +import com.todoroo.astrid.subtasks.OrderedListUpdater.OrderedListIterator; public class GtasksTaskListUpdater extends OrderedListUpdater { @@ -167,7 +168,7 @@ public class GtasksTaskListUpdater extends OrderedListUpdater { private void updateParentSiblingMapsFor(StoreObject list) { final AtomicLong previousTask = new AtomicLong(Task.NO_ID); - final AtomicInteger previousIndent = new AtomicInteger(0); + final AtomicInteger previousIndent = new AtomicInteger(-1); gtasksMetadataService.iterateThroughList(list, new OrderedListIterator() { @Override @@ -181,10 +182,7 @@ public class GtasksTaskListUpdater extends OrderedListUpdater { sibling = Task.NO_ID; } else if(indent == previousIndent.get()) { sibling = previousTask.get(); - if (parents.containsKey(sibling)) - parent = parents.get(sibling); - else - parent = Task.NO_ID; + parent = parents.get(sibling); } else { // move up once for each indent sibling = previousTask.get(); diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java index 7bef636e9..7066c6d14 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java @@ -47,6 +47,7 @@ import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncV2Provider; +import com.todoroo.astrid.sync.SyncV2Provider.SyncExceptionHandler; public class GtasksSyncV2Provider extends SyncV2Provider { @@ -183,8 +184,9 @@ public class GtasksSyncV2Provider extends SyncV2Provider { callback.incrementProgress(50); try { String authToken = getValidatedAuthToken(); - callback.incrementProgress(25); + callback.incrementProgress(12); gtasksSyncService.waitUntilEmpty(); + callback.incrementProgress(13); final GtasksInvoker service = new GtasksInvoker(authToken); synchronizeListHelper(gtasksList, service, manual, null, callback); } finally { diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java index f82826cd9..112193253 100644 --- a/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java +++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/OrderedListUpdater.java @@ -13,6 +13,7 @@ import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; +import com.todoroo.astrid.subtasks.OrderedListUpdater.OrderedListIterator; abstract public class OrderedListUpdater { @@ -82,7 +83,7 @@ abstract public class OrderedListUpdater { beforeIndent(list); - final AtomicInteger targetTaskIndent = new AtomicInteger(0); + final AtomicInteger targetTaskIndent = new AtomicInteger(-1); final AtomicInteger previousIndent = new AtomicInteger(-1); final AtomicLong previousTask = new AtomicLong(Task.NO_ID); final AtomicLong globalOrder = new AtomicLong(-1); @@ -163,7 +164,7 @@ abstract public class OrderedListUpdater { } }); - if (lastPotentialParent.get() == -1) return Task.NO_ID; + if (lastPotentialParent.get() == Task.NO_ID) return Task.NO_ID; return lastPotentialParent.get(); }