Search in sources :

Example 1 with TasksByDoneDateComparator

use of ve.com.abicelis.remindy.model.TasksByDoneDateComparator in project Remindy by abicelis.

the class TaskSortingUtil method generateDoneTaskHeaderList.

/* Done Tasks */
public ArrayList<TaskViewModel> generateDoneTaskHeaderList(List<Task> tasks, TaskSortType sortType, Resources resources) throws InvalidClassException {
    ArrayList<TaskViewModel> result = new ArrayList<>();
    clearTaskBuckets();
    if (sortType == TaskSortType.DATE) {
        //Sorting by doneDate!
        Collections.sort(tasks, new TasksByDoneDateComparator());
        for (Task current : tasks) {
            if (current.getReminderType() == null)
                throw new NullPointerException("NULL ReminderType passed into TaskSortingUtil.generateProgrammedTaskHeaderList()");
            insertDoneTaskIntoBucket(current, current.getDoneDate());
        }
        if (tasksToday.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_today), false));
            dumpTaskBucketIntoViewModelList(tasksToday, result);
        }
        if (tasksYesterday.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_yesterday), false));
            dumpTaskBucketIntoViewModelList(tasksYesterday, result);
        }
        if (tasksThisWeek.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_this_week), false));
            dumpTaskBucketIntoViewModelList(tasksThisWeek, result);
        }
        if (tasksLastWeek.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_last_week), false));
            dumpTaskBucketIntoViewModelList(tasksLastWeek, result);
        }
        if (tasksThisMonth.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_this_month), false));
            dumpTaskBucketIntoViewModelList(tasksThisMonth, result);
        }
        if (tasksLastMonth.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_last_month), false));
            dumpTaskBucketIntoViewModelList(tasksLastMonth, result);
        }
        if (tasksThisYear.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_this_year), false));
            dumpTaskBucketIntoViewModelList(tasksThisYear, result);
        }
        if (tasksLastYear.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_last_year), false));
            dumpTaskBucketIntoViewModelList(tasksLastYear, result);
        }
        if (tasksPast.size() > 0) {
            result.add(new TaskViewModel(resources.getString(R.string.task_header_past), false));
            dumpTaskBucketIntoViewModelList(tasksPast, result);
        }
    } else if (sortType == TaskSortType.PLACE) {
        handleSortingByPlace(tasks, result, resources);
    }
    return result;
}
Also used : Task(ve.com.abicelis.remindy.model.Task) TaskViewModel(ve.com.abicelis.remindy.viewmodel.TaskViewModel) TasksByDoneDateComparator(ve.com.abicelis.remindy.model.TasksByDoneDateComparator) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 Task (ve.com.abicelis.remindy.model.Task)1 TasksByDoneDateComparator (ve.com.abicelis.remindy.model.TasksByDoneDateComparator)1 TaskViewModel (ve.com.abicelis.remindy.viewmodel.TaskViewModel)1