The TODO App allows users to generate a TODO list with editable and sortable tasks. The demo includes a login activity and sign-up activity with input validation. After a user logs in or signs up, they can see a list of tasks. The demo provides options for the user to add, edit, delete, filter, and sort tasks from their TODO list.
To develop a TODO list app for Android following Model-View-Controller Architecture.
This project uses Material UI.
This project was coded in Android Studio.
To allow users to sort tasks by title, priority, and deadline, I wrote the following comparator classes.
/**
* Comparator to compare Task objects by priority (int)
*/
static class PriorityComparator implements Comparator<Task> {
@Override
public int compare(Task task1, Task task2)
{
if (task1.getPriority() == task2.getPriority()) {
return 0;
} else if (task1.getPriority() > task2.getPriority()) {
return 1;
}
return -1;
}
}
/**
* Comparator to compare Task objects by deadline (date)
*/
static class DeadlineComparator implements Comparator<Task> {
@Override
public int compare(Task task1, Task task2)
{
if (task1.getDeadline().equals(task2.getDeadline())) {
return 0;
} else if (task1.getDeadline().after(task2.getDeadline())) {
return 1;
}
return -1;
}
}
/**
* Comparator to compare Task objects by title (string)
*/
static class TitleComparator implements Comparator<Task> {
@Override
public int compare(Task task1, Task task2)
{
return task1.getTitle().toUpperCase().compareTo(task2.getTitle().toUpperCase());
}
}
These are called by sort methods:
/**
* Sort Task objects in mTasks by priority
*/
public void sortByPriority() {
mTasks.sort(new PriorityComparator());
}
/**
* Sort Task objects in mTasks by deadline
*/
public void sortByDeadline() {
mTasks.sort(new DeadlineComparator());
}
/**
* Sort Task objects in mTasks by title
*/
public void sortByTitle() {
mTasks.sort(new TitleComparator());
}
To allow users to filter by incomplete tasks and clear completed tasks, I wrote the following functions:
/**
* Get list of incomplete tasks
* @return List of incomplete Task objects
*/
public List<Task> getIncompleteTasks() {
ArrayList<Task> incompleteTasks = new ArrayList<>();
for (Task task: mTasks) {
if (!task.isCompleted()) {
incompleteTasks.add(task);
}
}
return incompleteTasks;
}
/**
* Clear completed tasks from mTasks
*/
public void clearCompletedTasks() {
mTasks.removeIf(Task::isCompleted);
}
I created a demo video using Adobe Premiere Pro. You can watch it here.