Removed another unecessary query in the tag filter exposer

pull/14/head
Sam Bosley 12 years ago
parent 1be758d198
commit 4264ca9409

@ -38,7 +38,6 @@ import com.todoroo.astrid.api.FilterCategory;
import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.api.FilterWithUpdate;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata;
@ -84,10 +83,8 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
filter.color = Color.GRAY;
}
TagData tagData = PluginServices.getTagDataService().getTag(tag.tag, TagData.ID,
TagData.USER_ID, TagData.MEMBER_COUNT);
int deleteIntentLabel;
if (tagData != null && tagData.getValue(TagData.MEMBER_COUNT) > 0 && tagData.getValue(TagData.USER_ID) != 0)
if (tag.memberCount > 0 && tag.userId != 0)
deleteIntentLabel = R.string.tag_cm_leave;
else
deleteIntentLabel = R.string.tag_cm_delete;
@ -119,9 +116,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
/** Create a filter from tag data object */
public static Filter filterFromTagData(Context context, TagData tagData) {
Tag tag = new Tag(tagData.getValue(TagData.NAME),
tagData.getValue(TagData.TASK_COUNT),
tagData.getValue(TagData.REMOTE_ID));
Tag tag = new Tag(tagData);
return filterFromTag(context, tag, TaskCriteria.activeAndVisible());
}

@ -117,6 +117,8 @@ public final class TagService {
public int count;
public long remoteId;
public String image;
public long userId;
public long memberCount;
public Tag(String tag, int count, long remoteId) {
this.tag = tag;
@ -129,6 +131,8 @@ public final class TagService {
count = tagData.getValue(TagData.TASK_COUNT);
remoteId = tagData.getValue(TagData.REMOTE_ID);
image = tagData.getValue(TagData.PICTURE);
userId = tagData.getValue(TagData.USER_ID);
memberCount = tagData.getValue(TagData.MEMBER_COUNT);
}
@Override

@ -189,7 +189,7 @@ public class TaskService {
return newTask;
}
public Task cloneReusableTask(Task task, String listName, long remoteId) {
public Task cloneReusableTask(Task task, String listName, long tagRemoteId) {
Task newTask = fetchById(task.getId(), Task.PROPERTIES);
if (newTask == null)
return new Task();
@ -205,8 +205,8 @@ public class TaskService {
tag.setValue(Metadata.TASK, newTask.getId());
tag.setValue(Metadata.KEY, TagService.KEY);
tag.setValue(TagService.TAG, listName);
if (remoteId > 0)
tag.setValue(TagService.REMOTE_ID, remoteId);
if (tagRemoteId > 0)
tag.setValue(TagService.REMOTE_ID, tagRemoteId);
metadataDao.createNew(tag);
}
return newTask;

Loading…
Cancel
Save