Search in sources :

Example 1 with TaskCategory

use of ve.com.abicelis.remindy.enums.TaskCategory in project Remindy by abicelis.

the class RemindyDAO method getTaskFromCursor.

/* Cursor to Model */
private Task getTaskFromCursor(Cursor cursor) {
    int id = cursor.getInt(cursor.getColumnIndex(RemindyContract.TaskTable._ID));
    TaskStatus status = TaskStatus.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_STATUS.getName())));
    String title = cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_TITLE.getName()));
    String description = cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_DESCRIPTION.getName()));
    TaskCategory category = TaskCategory.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_CATEGORY.getName())));
    ReminderType reminderType;
    try {
        reminderType = ReminderType.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_REMINDER_TYPE.getName())));
    } catch (IllegalArgumentException e) {
        //Thrown if task has no reminder
        reminderType = null;
    }
    Calendar doneDate = null;
    if (status == TaskStatus.DONE) {
        long doneDateLong = cursor.getLong(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_DONE_DATE.getName()));
        if (doneDateLong != -1) {
            doneDate = Calendar.getInstance();
            doneDate.setTimeInMillis(doneDateLong);
        }
    }
    return new Task(id, status, title, description, category, reminderType, null, doneDate);
}
Also used : Task(ve.com.abicelis.remindy.model.Task) TaskCategory(ve.com.abicelis.remindy.enums.TaskCategory) Calendar(java.util.Calendar) TaskStatus(ve.com.abicelis.remindy.enums.TaskStatus) ReminderType(ve.com.abicelis.remindy.enums.ReminderType)

Example 2 with TaskCategory

use of ve.com.abicelis.remindy.enums.TaskCategory in project Remindy by abicelis.

the class TaskFragment method updateData.

@Override
public void updateData() {
    TaskCategory category = TaskCategory.values()[mTaskCategory.getSelectedItemPosition()];
    mTask.setCategory(category);
    mTask.setTitle(mTaskTitle.getText().toString().trim());
    mTask.setDescription(mTaskDescription.getText().toString().trim());
}
Also used : TaskCategory(ve.com.abicelis.remindy.enums.TaskCategory)

Aggregations

TaskCategory (ve.com.abicelis.remindy.enums.TaskCategory)2 Calendar (java.util.Calendar)1 ReminderType (ve.com.abicelis.remindy.enums.ReminderType)1 TaskStatus (ve.com.abicelis.remindy.enums.TaskStatus)1 Task (ve.com.abicelis.remindy.model.Task)1