Search in sources :

Example 1 with ReminderRepeatType

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

the class RemindyDAO method getRepeatingReminderFromCursor.

private RepeatingReminder getRepeatingReminderFromCursor(Cursor cursor) {
    int id = cursor.getInt(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable._ID));
    int taskId = cursor.getInt(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_TASK_FK.getName()));
    Calendar date = Calendar.getInstance();
    date.setTimeInMillis(cursor.getLong(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_DATE.getName())));
    Time time = new Time(cursor.getInt(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_TIME.getName())));
    time.setDisplayTimeFormat(SharedPreferenceUtil.getTimeFormat(mContext));
    ReminderRepeatType repeatType = ReminderRepeatType.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_TYPE.getName())));
    int repeatInterval = cursor.getInt(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_INTERVAL.getName()));
    ReminderRepeatEndType repeatEndType = ReminderRepeatEndType.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_END_TYPE.getName())));
    int repeatEndNumberOfEvents = -1;
    if (repeatEndType == ReminderRepeatEndType.FOR_X_EVENTS)
        repeatEndNumberOfEvents = cursor.getInt(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_END_NUMBER_OF_EVENTS.getName()));
    Calendar repeatEndDate = null;
    if (repeatEndType == ReminderRepeatEndType.UNTIL_DATE) {
        repeatEndDate = Calendar.getInstance();
        repeatEndDate.setTimeInMillis(cursor.getLong(cursor.getColumnIndex(RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_END_DATE.getName())));
    }
    return new RepeatingReminder(id, taskId, date, time, repeatType, repeatInterval, repeatEndType, repeatEndNumberOfEvents, repeatEndDate);
}
Also used : ReminderRepeatType(ve.com.abicelis.remindy.enums.ReminderRepeatType) Calendar(java.util.Calendar) ReminderRepeatEndType(ve.com.abicelis.remindy.enums.ReminderRepeatEndType) RepeatingReminder(ve.com.abicelis.remindy.model.reminder.RepeatingReminder) Time(ve.com.abicelis.remindy.model.Time)

Aggregations

Calendar (java.util.Calendar)1 ReminderRepeatEndType (ve.com.abicelis.remindy.enums.ReminderRepeatEndType)1 ReminderRepeatType (ve.com.abicelis.remindy.enums.ReminderRepeatType)1 Time (ve.com.abicelis.remindy.model.Time)1 RepeatingReminder (ve.com.abicelis.remindy.model.reminder.RepeatingReminder)1