use of ve.com.abicelis.remindy.enums.TaskStatus 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);
}
Aggregations