Really minor cleanup for the awesome gtasks bug fixes

pull/14/head
Tim Su 13 years ago
parent c44b884f3a
commit 288a558ebe

@ -94,17 +94,13 @@ public class ContentResolverDao<TYPE extends AbstractModel> {
* @return true if data was written to the db, false otherwise * @return true if data was written to the db, false otherwise
*/ */
public boolean save(TYPE model) { public boolean save(TYPE model) {
boolean retainedTransitories = false; writeTransitoriesToModelContentValues(model);
if(model.isSaved()) { if(model.isSaved()) {
if(model.getSetValues() == null) if(model.getSetValues() == null)
return false; return false;
writeTransitoriesToModelContentValues(model);
retainedTransitories = true;
if(cr.update(uriWithId(model.getId()), model.getSetValues(), null, null) != 0) if(cr.update(uriWithId(model.getId()), model.getSetValues(), null, null) != 0)
return true; return true;
} }
if (!retainedTransitories)
writeTransitoriesToModelContentValues(model);
Uri uri = cr.insert(baseUri, model.getMergedValues()); Uri uri = cr.insert(baseUri, model.getMergedValues());
long id = Long.parseLong(uri.getLastPathSegment()); long id = Long.parseLong(uri.getLastPathSegment());
model.setId(id); model.setId(id);

@ -24,6 +24,7 @@ import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.sync.GtasksSyncService; import com.todoroo.astrid.gtasks.sync.GtasksSyncService;
import com.todoroo.astrid.subtasks.OrderedListUpdater; import com.todoroo.astrid.subtasks.OrderedListUpdater;
import com.todoroo.astrid.subtasks.OrderedListUpdater.OrderedListIterator;
public class GtasksTaskListUpdater extends OrderedListUpdater<StoreObject> { public class GtasksTaskListUpdater extends OrderedListUpdater<StoreObject> {
@ -167,7 +168,7 @@ public class GtasksTaskListUpdater extends OrderedListUpdater<StoreObject> {
private void updateParentSiblingMapsFor(StoreObject list) { private void updateParentSiblingMapsFor(StoreObject list) {
final AtomicLong previousTask = new AtomicLong(Task.NO_ID); 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() { gtasksMetadataService.iterateThroughList(list, new OrderedListIterator() {
@Override @Override
@ -181,10 +182,7 @@ public class GtasksTaskListUpdater extends OrderedListUpdater<StoreObject> {
sibling = Task.NO_ID; sibling = Task.NO_ID;
} else if(indent == previousIndent.get()) { } else if(indent == previousIndent.get()) {
sibling = previousTask.get(); sibling = previousTask.get();
if (parents.containsKey(sibling))
parent = parents.get(sibling); parent = parents.get(sibling);
else
parent = Task.NO_ID;
} else { } else {
// move up once for each indent // move up once for each indent
sibling = previousTask.get(); sibling = previousTask.get();

@ -47,6 +47,7 @@ import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.sync.SyncResultCallback; import com.todoroo.astrid.sync.SyncResultCallback;
import com.todoroo.astrid.sync.SyncV2Provider; import com.todoroo.astrid.sync.SyncV2Provider;
import com.todoroo.astrid.sync.SyncV2Provider.SyncExceptionHandler;
public class GtasksSyncV2Provider extends SyncV2Provider { public class GtasksSyncV2Provider extends SyncV2Provider {
@ -183,8 +184,9 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
callback.incrementProgress(50); callback.incrementProgress(50);
try { try {
String authToken = getValidatedAuthToken(); String authToken = getValidatedAuthToken();
callback.incrementProgress(25); callback.incrementProgress(12);
gtasksSyncService.waitUntilEmpty(); gtasksSyncService.waitUntilEmpty();
callback.incrementProgress(13);
final GtasksInvoker service = new GtasksInvoker(authToken); final GtasksInvoker service = new GtasksInvoker(authToken);
synchronizeListHelper(gtasksList, service, manual, null, callback); synchronizeListHelper(gtasksList, service, manual, null, callback);
} finally { } finally {

@ -13,6 +13,7 @@ import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.subtasks.OrderedListUpdater.OrderedListIterator;
abstract public class OrderedListUpdater<LIST> { abstract public class OrderedListUpdater<LIST> {
@ -82,7 +83,7 @@ abstract public class OrderedListUpdater<LIST> {
beforeIndent(list); beforeIndent(list);
final AtomicInteger targetTaskIndent = new AtomicInteger(0); final AtomicInteger targetTaskIndent = new AtomicInteger(-1);
final AtomicInteger previousIndent = new AtomicInteger(-1); final AtomicInteger previousIndent = new AtomicInteger(-1);
final AtomicLong previousTask = new AtomicLong(Task.NO_ID); final AtomicLong previousTask = new AtomicLong(Task.NO_ID);
final AtomicLong globalOrder = new AtomicLong(-1); final AtomicLong globalOrder = new AtomicLong(-1);
@ -163,7 +164,7 @@ abstract public class OrderedListUpdater<LIST> {
} }
}); });
if (lastPotentialParent.get() == -1) return Task.NO_ID; if (lastPotentialParent.get() == Task.NO_ID) return Task.NO_ID;
return lastPotentialParent.get(); return lastPotentialParent.get();
} }

Loading…
Cancel
Save