Back to project page NotAnotherTodoApp.
The source code is released under:
GNU General Public License
If you think the Android project NotAnotherTodoApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ca.ualberta.cs.notanothertodoapp; /*w w w. j a v a 2 s . c om*/ import java.util.ArrayList; import java.util.Collection; public class TodoList { /* TodoList Class to hold all your favorite Todos */ //List of the Todos protected ArrayList<Todo> todoList; //List of the Listeners protected ArrayList<Listener> listeners; //Constructor public TodoList() { todoList = new ArrayList<Todo>(); listeners = new ArrayList<Listener>(); } //Get the list of Todos public Collection<Todo> getTodos() { return todoList; } //Add a Todo public void addTodo(Todo todo) { todoList.add(todo); notifyListeners(); } //Remove a Todo public void removeTodo(Todo todo){ todoList.remove(todo); notifyListeners(); } //Toggle a Todo public void toggleTodo(Todo todo){ todo.toggleCheck(); notifyListeners(); } //Notify Listeners public void notifyListeners() { for (Listener listener : listeners) { listener.update(); } } //Add a listener public void addListener(Listener l) { listeners.add(l); } //Remove a listner public void removeListener(Listener l) { listeners.remove(l); } //Clear the list public void clear() { listeners.clear(); todoList.clear(); } //Get the string representation of the TodoList public String toString() { String string = ""; for (Todo todo : todoList) { string = string + todo.toStringRep() + "\n"; } return string; } }