@Override
 public List<PolyTodoItem> getSaveNeededTasks() {
   List<PolyTodoItem> saveNeededTasks = new ArrayList<>();
   for (PolyTodoItem item : localList) {
     if (item.isSaveNeeded()) saveNeededTasks.add(item);
   }
   return saveNeededTasks;
 }
 @Override
 public String getTaskId(int position) {
   String taskId = "";
   PolyTodoItem polyTodoItem = localList.get(position);
   if (polyTodoItem != null) {
     taskId = polyTodoItem.getId();
   }
   return taskId;
 }
 private PolyTodoItem getTaskById(String id) {
   PolyTodoItem found = null;
   for (PolyTodoItem item : localList) {
     if (id.equals(item.getId())) {
       found = item;
       break;
     }
   }
   return found;
 }
 @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);
     }
   }
 }
 public PolyTodoListImpl(TaskList taskList, List<Task> tasks, int color) {
   this.taskList = taskList;
   this.localList = new ArrayList<>();
   this.color = color;
   if (taskList != null && tasks != null) {
     String listId = taskList.getId();
     for (Task task : tasks) {
       if (task.getTitle().isEmpty()) break;
       PolyTodoItem polyTodoItem = new PolyTodoItemImpl(task, listId, color);
       localList.add(polyTodoItem);
       isPolyTodoList =
           isPolyTodoList
               && polyTodoItem
                   .isPolyTodoItem(); // If there is a non PolyTodoItem, isPolyTodoList is false.
     }
   }
 }
 @Override
 public PolyTodoItem getNextTask(PolyTodoItem item) {
   PolyTodoItem rtnTodoItem = null;
   if (item != null) {
     String itemId = item.getId();
     for (int i = 0; i < localList.size() - 1; i++) {
       String currentId = localList.get(i).getId();
       PolyTodoItem next = localList.get(i + 1);
       if (currentId.equals(itemId)) {
         rtnTodoItem = next;
         break;
       }
     }
   }
   return rtnTodoItem;
 }
 @Override
 public PolyTodoItem getPreviousTask(PolyTodoItem item) {
   PolyTodoItem rtnTodoItem = null;
   if (item != null) {
     String itemId = item.getId();
     for (int i = 1; i < localList.size(); i++) {
       PolyTodoItem previous = localList.get(i - 1);
       String currentId = localList.get(i).getId();
       if (currentId.equals(itemId)) {
         rtnTodoItem = previous;
         break;
       }
     }
   }
   return rtnTodoItem;
 }
 @Override
 public String getPreviousTaskId(PolyTodoItem item) {
   PolyTodoItem previous = getPreviousTask(item);
   return (previous != null) ? previous.getId() : "";
 }