Got label changing goodies to work out.

pull/14/head
Tim Su 16 years ago
parent 613516e06a
commit bccaf13d47

@ -68,6 +68,9 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail
// display dashboard if not "no sync" or "default" // display dashboard if not "no sync" or "default"
StoreObject ownerDashboard = null; StoreObject ownerDashboard = null;
for(StoreObject dashboard : ProducteevDataService.getInstance().getDashboards()) { for(StoreObject dashboard : ProducteevDataService.getInstance().getDashboards()) {
if(dashboard == null || !dashboard.containsNonNullValue(ProducteevDashboard.REMOTE_ID))
continue;
if(dashboard.getValue(ProducteevDashboard.REMOTE_ID) == dashboardId) { if(dashboard.getValue(ProducteevDashboard.REMOTE_ID) == dashboardId) {
ownerDashboard = dashboard; ownerDashboard = dashboard;
break; break;

@ -54,8 +54,8 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
private ProducteevInvoker invoker = null; private ProducteevInvoker invoker = null;
private final ProducteevUtilities preferences = ProducteevUtilities.INSTANCE; private final ProducteevUtilities preferences = ProducteevUtilities.INSTANCE;
/** map of producteev labels to id's */ /** map of producteev dashboard id + label name to id's */
private final HashMap<ProducteevLabel, Long> labelMap = new HashMap<ProducteevLabel, Long>(); private final HashMap<String, Long> labelMap = new HashMap<String, Long>();
static { static {
AstridDependencyInjector.initialize(); AstridDependencyInjector.initialize();
@ -477,22 +477,19 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
if(toAdd.size() > 0) { if(toAdd.size() > 0) {
for(String label : toAdd) { for(String label : toAdd) {
ProducteevLabel pdvLabel = new ProducteevLabel(); String pdvLabel = idDashboard + label;
pdvLabel.name = label;
pdvLabel.dashboard = idDashboard;
if(!labelMap.containsKey(pdvLabel)) { if(!labelMap.containsKey(pdvLabel)) {
JSONObject result = invoker.labelsCreate(idDashboard, label).getJSONObject("label"); JSONObject result = invoker.labelsCreate(idDashboard, label).getJSONObject("label");
putLabelIntoCache(result); long id = putLabelIntoCache(result);
} invoker.tasksSetLabel(idTask, id);
invoker.tasksSetLabel(idTask, labelMap.get(pdvLabel)); } else
invoker.tasksSetLabel(idTask, labelMap.get(pdvLabel));
} }
} }
if(toRemove.size() > 0) { if(toRemove.size() > 0) {
for(String label : toRemove) { for(String label : toRemove) {
ProducteevLabel pdvLabel = new ProducteevLabel(); String pdvLabel = idDashboard + label;
pdvLabel.name = label;
pdvLabel.dashboard = idDashboard;
if(!labelMap.containsKey(pdvLabel)) if(!labelMap.containsKey(pdvLabel))
continue; continue;
invoker.tasksUnsetLabel(idTask, labelMap.get(pdvLabel)); invoker.tasksUnsetLabel(idTask, labelMap.get(pdvLabel));
@ -608,11 +605,6 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
destination.pdvTask = source.pdvTask; destination.pdvTask = source.pdvTask;
} }
public class ProducteevLabel {
public String name;
public long dashboard;
}
/** /**
* Read labels into label map * Read labels into label map
* @param dashboardId * @param dashboardId
@ -633,12 +625,12 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
* @param label * @param label
* @throws JSONException * @throws JSONException
*/ */
private void putLabelIntoCache(JSONObject label) private long putLabelIntoCache(JSONObject label)
throws JSONException { throws JSONException {
ProducteevLabel labelContainer = new ProducteevLabel(); String name = ApiUtilities.decode(label.getString("title"));
labelContainer.name = ApiUtilities.decode(label.getString("title")); long dashboard = label.getLong("id_dashboard");
labelContainer.dashboard = label.getLong("id_dashboard"); labelMap.put(dashboard + name, label.getLong("id_label"));
labelMap.put(labelContainer, label.getLong("id_label")); return label.getLong("id_label");
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

Loading…
Cancel
Save