Fixed bugs relating to indentation and list refreshing

pull/14/head
Sam Bosley 12 years ago
parent 4c7139a7ce
commit fe79994c6a

@ -136,7 +136,9 @@ public class NewOrderedListFragmentHelper<LIST> {
Log.e("drag", "Drag Error", e); //$NON-NLS-1$ //$NON-NLS-2$
}
updater.writeSerialization(list, updater.serializeTree());
fragment.setUpTaskList();
updater.applyToFilter(getFilter());
fragment.reconstructCursor();
fragment.loadTaskListContent(true);
}
};
@ -160,7 +162,9 @@ public class NewOrderedListFragmentHelper<LIST> {
Log.e("drag", "Indent Error", e); //$NON-NLS-1$ //$NON-NLS-2$
}
updater.writeSerialization(list, updater.serializeTree());
fragment.setUpTaskList();
updater.applyToFilter(getFilter());
fragment.reconstructCursor();
fragment.loadTaskListContent(true);
}
};

@ -151,6 +151,7 @@ public abstract class NewOrderedListUpdater<LIST> {
node.parent = newParent;
newParent.children.add(node);
node.indent = newParent.indent + 1;
adjustDescendantsIndent(node, node.indent);
} else if (delta < 0) {
if (parent == treeRoot) // Can't deindent a top level item
return;
@ -166,10 +167,18 @@ public abstract class NewOrderedListUpdater<LIST> {
siblings.remove(index);
node.parent = newParent;
node.indent = newParent.indent + 1;
adjustDescendantsIndent(node, node.indent);
newSiblings.add(insertAfter + 1, node);
}
}
private void adjustDescendantsIndent(Node node, int baseIndent) {
for (Node child : node.children) {
child.indent = baseIndent + 1;
adjustDescendantsIndent(child, child.indent);
}
}
public void moveTo(long targetTaskId, long beforeTaskId) {
Node target = idToNode.get(targetTaskId);
if (target == null)
@ -194,13 +203,22 @@ public abstract class NewOrderedListUpdater<LIST> {
Node newParent = beforeThis.parent;
ArrayList<Node> newSiblings = newParent.children;
int index = newSiblings.indexOf(beforeThis);
if (index < 0)
int beforeIndex = newSiblings.indexOf(beforeThis);
if (beforeIndex < 0)
return;
int nodeIndex = oldSiblings.indexOf(moveThis);
if (nodeIndex < 0)
return;
moveThis.parent = newParent;
moveThis.indent = moveThis.parent.indent + 1;
oldSiblings.remove(moveThis);
newSiblings.add(index, moveThis);
if (newSiblings == oldSiblings && beforeIndex > nodeIndex) {
beforeIndex--;
}
newSiblings.add(beforeIndex, moveThis);
}
private void moveToEndOfList(Node moveThis) {

@ -895,11 +895,34 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
* @param withCustomId
* force task with given custom id to be part of list
*/
@SuppressWarnings("nls")
public void setUpTaskList() {
if (filter == null)
return;
TodorooCursor<Task> currentCursor = constructCursor();
if (currentCursor == null)
return;
// set up list adapters
taskAdapter = createTaskAdapter(currentCursor);
setListAdapter(taskAdapter);
getListView().setOnScrollListener(this);
registerForContextMenu(getListView());
loadTaskListContent(true);
}
public Property<?>[] taskProperties() {
return TaskAdapter.PROPERTIES;
}
public Filter getFilter() {
return filter;
}
@SuppressWarnings("nls")
private TodorooCursor<Task> constructCursor() {
String tagName = null;
if (getActiveTagData() != null)
tagName = getActiveTagData().getValue(TagData.NAME);
@ -936,35 +959,24 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
groupedQuery = sqlQueryTemplate.get() + " GROUP BY " + Task.ID;
sqlQueryTemplate.set(groupedQuery);
// perform query
TodorooCursor<Task> currentCursor;
// Peform query
try {
currentCursor = taskService.fetchFiltered(
return taskService.fetchFiltered(
sqlQueryTemplate.get(), null, taskProperties());
} catch (SQLiteException e) {
// We don't show this error anymore--seems like this can get triggered
// by a strange bug, but there seems to not be any negative side effect.
// For now, we'll suppress the error
// See http://astrid.com/home#tags-7tsoi/task-1119pk
return;
}
// set up list adapters
taskAdapter = createTaskAdapter(currentCursor);
setListAdapter(taskAdapter);
getListView().setOnScrollListener(this);
registerForContextMenu(getListView());
loadTaskListContent(true);
return null;
}
public Property<?>[] taskProperties() {
return TaskAdapter.PROPERTIES;
}
public Filter getFilter() {
return filter;
public void reconstructCursor() {
TodorooCursor<Task> cursor = constructCursor();
if (cursor == null)
return;
taskAdapter.changeCursor(cursor);
}
/**

Loading…
Cancel
Save