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;
import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener; import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
@ -117,13 +118,13 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
private final DropListener dropListener = new DropListener() { private final DropListener dropListener = new DropListener() {
@Override @Override
public void drop(int from, int to) { public void drop(int from, int to) {
long targetTaskId = taskAdapter.getItemId(from); String targetTaskId = taskAdapter.getItemUuid(from);
if (targetTaskId <= 0) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks) if (!RemoteModel.isValidUuid(targetTaskId)) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks)
long destinationTaskId = taskAdapter.getItemId(to); String destinationTaskId = taskAdapter.getItemUuid(to);
try { try {
if(to >= getListView().getCount()) if(to >= getListView().getCount())
updater.moveTo(list, getFilter(), targetTaskId, -1); updater.moveTo(list, getFilter(), targetTaskId, "-1"); //$NON-NLS-1$
else else
updater.moveTo(list, getFilter(), targetTaskId, destinationTaskId); updater.moveTo(list, getFilter(), targetTaskId, destinationTaskId);
} catch (Exception e) { } catch (Exception e) {
@ -147,8 +148,8 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
} }
protected void indent(int which, int delta) { protected void indent(int which, int delta) {
long targetTaskId = taskAdapter.getItemId(which); String targetTaskId = taskAdapter.getItemUuid(which);
if (targetTaskId <= 0) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks) if (!RemoteModel.isValidUuid(targetTaskId)) return; // This can happen with gestures on empty parts of the list (e.g. extra space below tasks)
try { try {
updater.indent(list, getFilter(), targetTaskId, delta); updater.indent(list, getFilter(), targetTaskId, delta);
} catch (Exception e) { } catch (Exception e) {
@ -218,7 +219,7 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
super.setFieldContentsAndVisibility(view); super.setFieldContentsAndVisibility(view);
ViewHolder vh = (ViewHolder) view.getTag(); 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); 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 static class Node {
// public long taskId; public String uuid;
public String uuid; // For parsing and syncing -- not used elsewhere
public Node parent; public Node parent;
public int indent; public int indent;
public final ArrayList<Node> children = new ArrayList<Node>(); public final ArrayList<Node> children = new ArrayList<Node>();
public Node(String uuid, Node parent, int indent) { public Node(String uuid, Node parent, int indent) {
// this.taskId = taskId;
this.uuid = uuid; this.uuid = uuid;
// this.uuid = "-1"; //$NON-NLS-1$
this.parent = parent; this.parent = parent;
this.indent = indent; 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 writeSerialization(LIST list, String serialized, boolean shouldQueueSync);
protected abstract void applyToFilter(Filter filter); protected abstract void applyToFilter(Filter filter);
public int getIndentForTask(long targetTaskId) { public int getIndentForTask(String targetTaskId) {
Node n = idToNode.get(targetTaskId); Node n = idToNode.get(targetTaskId);
if (n == null) if (n == null)
return 0; return 0;
@ -184,7 +181,7 @@ public abstract class AstridOrderedListUpdater<LIST> {
applyToDescendantsHelper(treeRoot, visitor); 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); Node node = idToNode.get(targetTaskId);
indentHelper(list, filter, node, delta); 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); Node target = idToNode.get(targetTaskId);
if (target == null) if (target == null)
return; return;
if (beforeTaskId == -1) { if ("-1".equals(beforeTaskId)) { //$NON-NLS-1$
moveToEndOfList(list, filter, target); moveToEndOfList(list, filter, target);
return; return;
} }

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

@ -430,6 +430,19 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
setTaskAppearance(viewHolder, task); 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. * View Holder saves a lot of findViewById lookups.
* *

Loading…
Cancel
Save