From bccaf13d4779c871b58aace25ddb88d4f39d2d95 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Fri, 13 Aug 2010 03:42:23 -0700 Subject: [PATCH] Got label changing goodies to work out. --- .../producteev/ProducteevDetailExposer.java | 3 ++ .../sync/ProducteevSyncProvider.java | 34 +++++++------------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java index c26ee6cc0..fc3e2f38b 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java @@ -68,6 +68,9 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail // display dashboard if not "no sync" or "default" StoreObject ownerDashboard = null; for(StoreObject dashboard : ProducteevDataService.getInstance().getDashboards()) { + if(dashboard == null || !dashboard.containsNonNullValue(ProducteevDashboard.REMOTE_ID)) + continue; + if(dashboard.getValue(ProducteevDashboard.REMOTE_ID) == dashboardId) { ownerDashboard = dashboard; break; diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java index 4c22a5607..e3d020016 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -54,8 +54,8 @@ public class ProducteevSyncProvider extends SyncProvider labelMap = new HashMap(); + /** map of producteev dashboard id + label name to id's */ + private final HashMap labelMap = new HashMap(); static { AstridDependencyInjector.initialize(); @@ -477,22 +477,19 @@ public class ProducteevSyncProvider extends SyncProvider 0) { for(String label : toAdd) { - ProducteevLabel pdvLabel = new ProducteevLabel(); - pdvLabel.name = label; - pdvLabel.dashboard = idDashboard; + String pdvLabel = idDashboard + label; if(!labelMap.containsKey(pdvLabel)) { JSONObject result = invoker.labelsCreate(idDashboard, label).getJSONObject("label"); - putLabelIntoCache(result); - } - invoker.tasksSetLabel(idTask, labelMap.get(pdvLabel)); + long id = putLabelIntoCache(result); + invoker.tasksSetLabel(idTask, id); + } else + invoker.tasksSetLabel(idTask, labelMap.get(pdvLabel)); } } if(toRemove.size() > 0) { for(String label : toRemove) { - ProducteevLabel pdvLabel = new ProducteevLabel(); - pdvLabel.name = label; - pdvLabel.dashboard = idDashboard; + String pdvLabel = idDashboard + label; if(!labelMap.containsKey(pdvLabel)) continue; invoker.tasksUnsetLabel(idTask, labelMap.get(pdvLabel)); @@ -608,11 +605,6 @@ public class ProducteevSyncProvider extends SyncProvider