Fix compilation errors from previous commit, brought over more changes from experimental branch

pull/14/head
Sam Bosley 12 years ago
parent 8dd89107a7
commit 7b244da3b9

@ -122,6 +122,13 @@ public final class TagService {
public long userId; public long userId;
public long memberCount; 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) { public Tag(TagData tagData) {
id = tagData.getId(); id = tagData.getId();
tag = tagData.getValue(TagData.NAME); tag = tagData.getValue(TagData.NAME);

@ -119,14 +119,13 @@ public class FeaturedTaskListFragment extends TagViewFragment {
return; return;
} }
final String localName = tagData.getValue(TagData.NAME) + " " + getString(R.string.actfm_feat_list_suffix); //$NON-NLS-1$ final String localName = tagData.getValue(TagData.NAME) + " " + getString(R.string.actfm_feat_list_suffix); //$NON-NLS-1$
long remoteId = 0; TagData clone = new TagData();
TodorooCursor<TagData> existing = tagDataService.query(Query.select(TagData.REMOTE_ID) TodorooCursor<TagData> existing = tagDataService.query(Query.select(TagData.PROPERTIES)
.where(TagData.NAME.eqCaseInsensitive(localName))); .where(TagData.NAME.eqCaseInsensitive(localName)));
try { try {
if (existing.getCount() > 0) { if (existing.getCount() > 0) {
existing.moveToFirst(); existing.moveToFirst();
TagData match = new TagData(existing); clone = new TagData(existing);
remoteId = match.getValue(TagData.REMOTE_ID);
} }
} finally { } finally {
@ -135,7 +134,7 @@ public class FeaturedTaskListFragment extends TagViewFragment {
final ProgressDialog pd = DialogUtilities.progressDialog(getActivity(), getString(R.string.actfm_feat_list_cloning)); 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() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -144,8 +143,7 @@ public class FeaturedTaskListFragment extends TagViewFragment {
Task t = new Task(); Task t = new Task();
for (tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) { for (tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) {
t.readFromCursor(tasks); t.readFromCursor(tasks);
taskService.cloneReusableTask(t, taskService.cloneReusableTask(t, finalTagData.getId());
localName, finalRemoteId);
} }
final Activity activity = getActivity(); final Activity activity = getActivity();
if (activity != null) { if (activity != null) {
@ -162,7 +160,7 @@ public class FeaturedTaskListFragment extends TagViewFragment {
tla.setFilterMode(TaskListActivity.FILTER_MODE_NORMAL); tla.setFilterMode(TaskListActivity.FILTER_MODE_NORMAL);
Filter clonedFilter; Filter clonedFilter;
Tag tag = new Tag(localName, tasks.getCount(), finalRemoteId); Tag tag = new Tag(finalTagData);
clonedFilter = TagFilterExposer.filterFromTag(activity, tag, TaskCriteria.activeAndVisible()); clonedFilter = TagFilterExposer.filterFromTag(activity, tag, TaskCriteria.activeAndVisible());
tla.onFilterItemClicked(clonedFilter); tla.onFilterItemClicked(clonedFilter);

@ -49,7 +49,7 @@ public class ReusableTaskAdapter extends TaskAdapter {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
ReusableTaskViewHolder holder = (ReusableTaskViewHolder) v.getTag(); 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(); Toast.makeText(fragment.getActivity(), R.string.actfm_feat_list_task_clone_success, Toast.LENGTH_LONG).show();
Flags.set(Flags.REFRESH); Flags.set(Flags.REFRESH);
} }

@ -31,9 +31,11 @@ import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.dao.TaskToTagDao;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.SyncFlags; import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskToTag;
import com.todoroo.astrid.gcal.GCalHelper; import com.todoroo.astrid.gcal.GCalHelper;
import com.todoroo.astrid.gtasks.GtasksMetadata; import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.opencrx.OpencrxCoreUtils; import com.todoroo.astrid.opencrx.OpencrxCoreUtils;
@ -71,6 +73,9 @@ public class TaskService {
@Autowired @Autowired
private MetadataDao metadataDao; private MetadataDao metadataDao;
@Autowired
private TaskToTagDao taskToTagDao;
public TaskService() { public TaskService() {
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
} }
@ -189,7 +194,7 @@ public class TaskService {
return newTask; 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); Task newTask = fetchById(task.getId(), Task.PROPERTIES);
if (newTask == null) if (newTask == null)
return new Task(); return new Task();
@ -200,14 +205,11 @@ public class TaskService {
taskDao.save(newTask); taskDao.save(newTask);
if (listName != null) { if (tagId > 0) {
Metadata tag = new Metadata(); TaskToTag link = new TaskToTag();
tag.setValue(Metadata.TASK, newTask.getId()); link.setValue(TaskToTag.ID, newTask.getId());
tag.setValue(Metadata.KEY, TagService.KEY); link.setValue(TaskToTag.TAG_ID, tagId);
tag.setValue(TagService.TAG, listName); taskToTagDao.createNew(link);
if (tagRemoteId > 0)
tag.setValue(TagService.REMOTE_ID, tagRemoteId);
metadataDao.createNew(tag);
} }
return newTask; return newTask;
} }

Loading…
Cancel
Save