From 7b244da3b91f07845968e2e86c6ebcb27704bf46 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 14 Sep 2012 11:09:16 -0700 Subject: [PATCH] Fix compilation errors from previous commit, brought over more changes from experimental branch --- .../com/todoroo/astrid/tags/TagService.java | 7 +++++++ .../reusable/FeaturedTaskListFragment.java | 14 ++++++------- .../tags/reusable/ReusableTaskAdapter.java | 2 +- .../todoroo/astrid/service/TaskService.java | 20 ++++++++++--------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java index 089f66983..10cb2d4b5 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java @@ -122,6 +122,13 @@ public final class TagService { public long userId; public long memberCount; + @Deprecated + private Tag(String tag, int count, long remoteId) { + this.tag = tag; + this.count = count; + this.remoteId = remoteId; + } + public Tag(TagData tagData) { id = tagData.getId(); tag = tagData.getValue(TagData.NAME); diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/reusable/FeaturedTaskListFragment.java b/astrid/plugin-src/com/todoroo/astrid/tags/reusable/FeaturedTaskListFragment.java index df09acb0f..429782a00 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/reusable/FeaturedTaskListFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/reusable/FeaturedTaskListFragment.java @@ -119,14 +119,13 @@ public class FeaturedTaskListFragment extends TagViewFragment { return; } final String localName = tagData.getValue(TagData.NAME) + " " + getString(R.string.actfm_feat_list_suffix); //$NON-NLS-1$ - long remoteId = 0; - TodorooCursor existing = tagDataService.query(Query.select(TagData.REMOTE_ID) + TagData clone = new TagData(); + TodorooCursor existing = tagDataService.query(Query.select(TagData.PROPERTIES) .where(TagData.NAME.eqCaseInsensitive(localName))); try { if (existing.getCount() > 0) { existing.moveToFirst(); - TagData match = new TagData(existing); - remoteId = match.getValue(TagData.REMOTE_ID); + clone = new TagData(existing); } } finally { @@ -135,7 +134,7 @@ public class FeaturedTaskListFragment extends TagViewFragment { final ProgressDialog pd = DialogUtilities.progressDialog(getActivity(), getString(R.string.actfm_feat_list_cloning)); - final long finalRemoteId = remoteId; + final TagData finalTagData = clone; new Thread(new Runnable() { @Override public void run() { @@ -144,8 +143,7 @@ public class FeaturedTaskListFragment extends TagViewFragment { Task t = new Task(); for (tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) { t.readFromCursor(tasks); - taskService.cloneReusableTask(t, - localName, finalRemoteId); + taskService.cloneReusableTask(t, finalTagData.getId()); } final Activity activity = getActivity(); if (activity != null) { @@ -162,7 +160,7 @@ public class FeaturedTaskListFragment extends TagViewFragment { tla.setFilterMode(TaskListActivity.FILTER_MODE_NORMAL); Filter clonedFilter; - Tag tag = new Tag(localName, tasks.getCount(), finalRemoteId); + Tag tag = new Tag(finalTagData); clonedFilter = TagFilterExposer.filterFromTag(activity, tag, TaskCriteria.activeAndVisible()); tla.onFilterItemClicked(clonedFilter); diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/reusable/ReusableTaskAdapter.java b/astrid/plugin-src/com/todoroo/astrid/tags/reusable/ReusableTaskAdapter.java index 781c93fb3..4378e4622 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/reusable/ReusableTaskAdapter.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/reusable/ReusableTaskAdapter.java @@ -49,7 +49,7 @@ public class ReusableTaskAdapter extends TaskAdapter { @Override public void onClick(View v) { ReusableTaskViewHolder holder = (ReusableTaskViewHolder) v.getTag(); - taskService.cloneReusableTask(holder.task, null, 0); + taskService.cloneReusableTask(holder.task, 0L); Toast.makeText(fragment.getActivity(), R.string.actfm_feat_list_task_clone_success, Toast.LENGTH_LONG).show(); Flags.set(Flags.REFRESH); } diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java index 17a983963..75604ddd3 100644 --- a/astrid/src/com/todoroo/astrid/service/TaskService.java +++ b/astrid/src/com/todoroo/astrid/service/TaskService.java @@ -31,9 +31,11 @@ import com.todoroo.astrid.dao.MetadataDao; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao.TaskCriteria; +import com.todoroo.astrid.dao.TaskToTagDao; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.SyncFlags; import com.todoroo.astrid.data.Task; +import com.todoroo.astrid.data.TaskToTag; import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.gtasks.GtasksMetadata; import com.todoroo.astrid.opencrx.OpencrxCoreUtils; @@ -71,6 +73,9 @@ public class TaskService { @Autowired private MetadataDao metadataDao; + @Autowired + private TaskToTagDao taskToTagDao; + public TaskService() { DependencyInjectionService.getInstance().inject(this); } @@ -189,7 +194,7 @@ public class TaskService { return newTask; } - public Task cloneReusableTask(Task task, String listName, long tagRemoteId) { + public Task cloneReusableTask(Task task, long tagId) { Task newTask = fetchById(task.getId(), Task.PROPERTIES); if (newTask == null) return new Task(); @@ -200,14 +205,11 @@ public class TaskService { taskDao.save(newTask); - if (listName != null) { - Metadata tag = new Metadata(); - tag.setValue(Metadata.TASK, newTask.getId()); - tag.setValue(Metadata.KEY, TagService.KEY); - tag.setValue(TagService.TAG, listName); - if (tagRemoteId > 0) - tag.setValue(TagService.REMOTE_ID, tagRemoteId); - metadataDao.createNew(tag); + if (tagId > 0) { + TaskToTag link = new TaskToTag(); + link.setValue(TaskToTag.ID, newTask.getId()); + link.setValue(TaskToTag.TAG_ID, tagId); + taskToTagDao.createNew(link); } return newTask; }