@Override public void moveDownTask(String id) { PolyTodoItem item = getTaskById(id); if (item != null) { int index = item.getLocalPosition(); if (index > 0) { // Swap position in localList PolyTodoItem next = localList.get(index + 1); localList.set(index, next); localList.set(index + 1, item); // Update local position in each PolyTodoItems next.setLocalPosition(index); item.setLocalPosition(index + 1); } } }
@Override public void moveUpTask(String id) { PolyTodoItem item = getTaskById(id); if (item != null) { int index = item.getLocalPosition(); if (index > 0) { // Swap position in localList PolyTodoItem previous = localList.get(index - 1); localList.set(index - 1, item); localList.set(index, previous); // Update local position in each PolyTodoItems item.setLocalPosition(index - 1); previous.setLocalPosition(index); } } }