Fixed some bugs related to subtasks using -1 instead of Task.NO_ID

pull/14/head
Sam Bosley 13 years ago
parent 982d9b1e0a
commit f0d453e0a3

@ -191,7 +191,6 @@ public final class GtasksMetadataService extends SyncMetadataService<GtasksTaskC
final AtomicInteger indentToMatch = new AtomicInteger(gtasksMetadata.getValue(GtasksMetadata.INDENT).intValue()); final AtomicInteger indentToMatch = new AtomicInteger(gtasksMetadata.getValue(GtasksMetadata.INDENT).intValue());
final AtomicLong parentToMatch = new AtomicLong(gtasksMetadata.getValue(GtasksMetadata.PARENT_TASK).longValue()); final AtomicLong parentToMatch = new AtomicLong(gtasksMetadata.getValue(GtasksMetadata.PARENT_TASK).longValue());
final AtomicReference<String> sibling = new AtomicReference<String>(); final AtomicReference<String> sibling = new AtomicReference<String>();
OrderedListIterator iterator = new OrderedListIterator() { OrderedListIterator iterator = new OrderedListIterator() {
@Override @Override
public void processTask(long taskId, Metadata metadata) { public void processTask(long taskId, Metadata metadata) {

@ -166,8 +166,8 @@ public class GtasksTaskListUpdater extends OrderedListUpdater<StoreObject> {
} }
private void updateParentSiblingMapsFor(StoreObject list) { private void updateParentSiblingMapsFor(StoreObject list) {
final AtomicLong previousTask = new AtomicLong(-1L); final AtomicLong previousTask = new AtomicLong(Task.NO_ID);
final AtomicInteger previousIndent = new AtomicInteger(-1); final AtomicInteger previousIndent = new AtomicInteger(0);
gtasksMetadataService.iterateThroughList(list, new OrderedListIterator() { gtasksMetadataService.iterateThroughList(list, new OrderedListIterator() {
@Override @Override
@ -178,10 +178,13 @@ public class GtasksTaskListUpdater extends OrderedListUpdater<StoreObject> {
long parent, sibling; long parent, sibling;
if(indent > previousIndent.get()) { if(indent > previousIndent.get()) {
parent = previousTask.get(); parent = previousTask.get();
sibling = -1L; sibling = Task.NO_ID;
} else if(indent == previousIndent.get()) { } else if(indent == previousIndent.get()) {
sibling = previousTask.get(); sibling = previousTask.get();
if (parents.containsKey(sibling))
parent = parents.get(sibling); parent = parents.get(sibling);
else
parent = Task.NO_ID;
} else { } else {
// move up once for each indent // move up once for each indent
sibling = previousTask.get(); sibling = previousTask.get();
@ -190,7 +193,7 @@ public class GtasksTaskListUpdater extends OrderedListUpdater<StoreObject> {
if(parents.containsKey(sibling)) if(parents.containsKey(sibling))
parent = parents.get(sibling); parent = parents.get(sibling);
else else
parent = -1L; parent = Task.NO_ID;
} }
parents.put(taskId, parent); parents.put(taskId, parent);
siblings.put(taskId, sibling); siblings.put(taskId, sibling);

@ -82,9 +82,9 @@ abstract public class OrderedListUpdater<LIST> {
beforeIndent(list); beforeIndent(list);
final AtomicInteger targetTaskIndent = new AtomicInteger(-1); final AtomicInteger targetTaskIndent = new AtomicInteger(0);
final AtomicInteger previousIndent = new AtomicInteger(-1); final AtomicInteger previousIndent = new AtomicInteger(-1);
final AtomicLong previousTask = new AtomicLong(-1); final AtomicLong previousTask = new AtomicLong(Task.NO_ID);
final AtomicLong globalOrder = new AtomicLong(-1); final AtomicLong globalOrder = new AtomicLong(-1);
iterateThroughList(filter, list, new OrderedListIterator() { iterateThroughList(filter, list, new OrderedListIterator() {
@ -146,7 +146,7 @@ abstract public class OrderedListUpdater<LIST> {
private long computeNewParent(Filter filter, LIST list, long targetTaskId, int targetParentIndent) { private long computeNewParent(Filter filter, LIST list, long targetTaskId, int targetParentIndent) {
final AtomicInteger desiredParentIndent = new AtomicInteger(targetParentIndent); final AtomicInteger desiredParentIndent = new AtomicInteger(targetParentIndent);
final AtomicLong targetTask = new AtomicLong(targetTaskId); final AtomicLong targetTask = new AtomicLong(targetTaskId);
final AtomicLong lastPotentialParent = new AtomicLong(-1); final AtomicLong lastPotentialParent = new AtomicLong(Task.NO_ID);
final AtomicBoolean computedParent = new AtomicBoolean(false); final AtomicBoolean computedParent = new AtomicBoolean(false);
iterateThroughList(filter, list, new OrderedListIterator() { iterateThroughList(filter, list, new OrderedListIterator() {
@ -228,7 +228,7 @@ abstract public class OrderedListUpdater<LIST> {
} }
protected void traverseTreeAndWriteValues(LIST list, Node node, AtomicLong order, int indent) { protected void traverseTreeAndWriteValues(LIST list, Node node, AtomicLong order, int indent) {
if(node.taskId != -1) { if(node.taskId != Task.NO_ID) {
Metadata metadata = getTaskMetadata(list, node.taskId); Metadata metadata = getTaskMetadata(list, node.taskId);
if(metadata == null) if(metadata == null)
metadata = createEmptyMetadata(list, node.taskId); metadata = createEmptyMetadata(list, node.taskId);
@ -262,7 +262,7 @@ abstract public class OrderedListUpdater<LIST> {
} }
protected Node buildTreeModel(Filter filter, LIST list) { protected Node buildTreeModel(Filter filter, LIST list) {
final Node root = new Node(-1, null); final Node root = new Node(Task.NO_ID, null);
final AtomicInteger previoustIndent = new AtomicInteger(-1); final AtomicInteger previoustIndent = new AtomicInteger(-1);
final AtomicReference<Node> currentNode = new AtomicReference<Node>(root); final AtomicReference<Node> currentNode = new AtomicReference<Node>(root);
@ -364,7 +364,7 @@ abstract public class OrderedListUpdater<LIST> {
System.err.format("id %d: order %d, indent:%d, parent:%d\n", taskId, //$NON-NLS-1$ System.err.format("id %d: order %d, indent:%d, parent:%d\n", taskId, //$NON-NLS-1$
metadata.getValue(orderProperty()), metadata.getValue(orderProperty()),
metadata.getValue(indentProperty()), metadata.getValue(indentProperty()),
parentProperty() == null ? -1 : metadata.getValue(parentProperty())); parentProperty() == null ? Task.NO_ID : metadata.getValue(parentProperty()));
} }
}); });
} }

Loading…
Cancel
Save