Fixed several type errors in subtasks code

pull/14/head
Sam Bosley 13 years ago
parent 841c5b178f
commit ef2bc10379

@ -33,6 +33,7 @@ import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TaskService;
@ -117,13 +118,13 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
private final DropListener dropListener = new DropListener() {
@Override
public void drop(int from, int to) {
long targetTaskId = taskAdapter.getItemId(from);
if (targetTaskId <= 0) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks)
long destinationTaskId = taskAdapter.getItemId(to);
String targetTaskId = taskAdapter.getItemUuid(from);
if (!RemoteModel.isValidUuid(targetTaskId)) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks)
String destinationTaskId = taskAdapter.getItemUuid(to);
try {
if(to >= getListView().getCount())
updater.moveTo(list, getFilter(), targetTaskId, -1);
updater.moveTo(list, getFilter(), targetTaskId, "-1"); //$NON-NLS-1$
else
updater.moveTo(list, getFilter(), targetTaskId, destinationTaskId);
} catch (Exception e) {
@ -147,8 +148,8 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
}
protected void indent(int which, int delta) {
long targetTaskId = taskAdapter.getItemId(which);
if (targetTaskId <= 0) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks)
String targetTaskId = taskAdapter.getItemUuid(which);
if (!RemoteModel.isValidUuid(targetTaskId)) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks)
try {
updater.indent(list, getFilter(), targetTaskId, delta);
} catch (Exception e) {
@ -218,7 +219,7 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
super.setFieldContentsAndVisibility(view);
ViewHolder vh = (ViewHolder) view.getTag();
int indent = updater.getIndentForTask(vh.task.getId());
int indent = updater.getIndentForTask(vh.task.getUuid());
vh.rowBody.setPadding(Math.round(indent * 20 * metrics.density), 0, 0, 0);
}

@ -34,16 +34,13 @@ public abstract class AstridOrderedListUpdater<LIST> {
}
public static class Node {
// public long taskId;
public String uuid; // For parsing and syncing -- not used elsewhere
public String uuid;
public Node parent;
public int indent;
public final ArrayList<Node> children = new ArrayList<Node>();
public Node(String uuid, Node parent, int indent) {
// this.taskId = taskId;
this.uuid = uuid;
// this.uuid = "-1"; //$NON-NLS-1$
this.parent = parent;
this.indent = indent;
}
@ -57,7 +54,7 @@ public abstract class AstridOrderedListUpdater<LIST> {
protected abstract void writeSerialization(LIST list, String serialized, boolean shouldQueueSync);
protected abstract void applyToFilter(Filter filter);
public int getIndentForTask(long targetTaskId) {
public int getIndentForTask(String targetTaskId) {
Node n = idToNode.get(targetTaskId);
if (n == null)
return 0;
@ -184,7 +181,7 @@ public abstract class AstridOrderedListUpdater<LIST> {
applyToDescendantsHelper(treeRoot, visitor);
}
public void indent(LIST list, Filter filter, long targetTaskId, int delta) {
public void indent(LIST list, Filter filter, String targetTaskId, int delta) {
Node node = idToNode.get(targetTaskId);
indentHelper(list, filter, node, delta);
}
@ -242,12 +239,12 @@ public abstract class AstridOrderedListUpdater<LIST> {
}
}
public void moveTo(LIST list, Filter filter, long targetTaskId, long beforeTaskId) {
public void moveTo(LIST list, Filter filter, String targetTaskId, String beforeTaskId) {
Node target = idToNode.get(targetTaskId);
if (target == null)
return;
if (beforeTaskId == -1) {
if ("-1".equals(beforeTaskId)) { //$NON-NLS-1$
moveToEndOfList(list, filter, target);
return;
}

@ -28,7 +28,7 @@ public class SubtasksTagUpdater extends SubtasksFilterUpdater {
}
@Override
public int getIndentForTask(long targetTaskId) {
public int getIndentForTask(String targetTaskId) {
if (isBeingFiltered.get())
return 0;
return super.getIndentForTask(targetTaskId);

@ -430,6 +430,19 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
setTaskAppearance(viewHolder, task);
}
public String getItemUuid(int position) {
TodorooCursor<Task> c = (TodorooCursor<Task>) getCursor();
if (c != null) {
if (c.moveToPosition(position)) {
return c.get(Task.UUID);
} else {
return RemoteModel.NO_UUID;
}
} else {
return RemoteModel.NO_UUID;
}
}
/**
* View Holder saves a lot of findViewById lookups.
*

Loading…
Cancel
Save