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 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);

@ -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<TagData> existing = tagDataService.query(Query.select(TagData.REMOTE_ID)
TagData clone = new TagData();
TodorooCursor<TagData> 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);

@ -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);
}

@ -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;
}

Loading…
Cancel
Save