From fb21f68b841102762bdd1e4ec3005329b0b713a3 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Tue, 30 Oct 2012 17:19:48 -0700 Subject: [PATCH] Implemented move in the new ordered list updater --- .../subtasks/NewOrderedListUpdater.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/astrid/plugin-src/com/todoroo/astrid/subtasks/NewOrderedListUpdater.java b/astrid/plugin-src/com/todoroo/astrid/subtasks/NewOrderedListUpdater.java index 1a6644785..65bbba5eb 100644 --- a/astrid/plugin-src/com/todoroo/astrid/subtasks/NewOrderedListUpdater.java +++ b/astrid/plugin-src/com/todoroo/astrid/subtasks/NewOrderedListUpdater.java @@ -85,6 +85,27 @@ public abstract class NewOrderedListUpdater { } } + public void moveTo(long targetTaskId, long beforeTaskId) { + Node target = idToNode.get(targetTaskId); + Node before = idToNode.get(beforeTaskId); + + if (target == null || before == null) + return; + moveHelper(target, before); + } + + private void moveHelper(Node moveThis, Node beforeThis) { + Node parent = beforeThis.parent; + ArrayList siblings = parent.children; + + int index = siblings.indexOf(beforeThis); + if (index < 0) + return; + + moveThis.parent = parent; + siblings.add(index, moveThis); + } + private Node buildTreeModel(String serializedTree) { Node root = new Node(-1, null); try {