use of ve.com.abicelis.remindy.model.Time 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);
}
use of ve.com.abicelis.remindy.model.Time in project Remindy by abicelis.
the class RemindyDAO method getOneTimeReminderFromCursor.
private OneTimeReminder getOneTimeReminderFromCursor(Cursor cursor) {
int id = cursor.getInt(cursor.getColumnIndex(RemindyContract.OneTimeReminderTable._ID));
int taskId = cursor.getInt(cursor.getColumnIndex(RemindyContract.OneTimeReminderTable.COLUMN_NAME_TASK_FK.getName()));
Calendar date = Calendar.getInstance();
date.setTimeInMillis(cursor.getLong(cursor.getColumnIndex(RemindyContract.OneTimeReminderTable.COLUMN_NAME_DATE.getName())));
Time time = new Time(cursor.getInt(cursor.getColumnIndex(RemindyContract.OneTimeReminderTable.COLUMN_NAME_TIME.getName())));
time.setDisplayTimeFormat(SharedPreferenceUtil.getTimeFormat(mContext));
return new OneTimeReminder(id, taskId, date, time);
}
use of ve.com.abicelis.remindy.model.Time in project Remindy by abicelis.
the class EditOneTimeReminderFragment method setupDateAndTimePickers.
private void setupDateAndTimePickers() {
final Calendar mToday = Calendar.getInstance();
final Calendar mTomorrow = Calendar.getInstance();
mTomorrow.add(Calendar.DAY_OF_MONTH, 1);
mDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDatePicker = new CalendarDatePickerDialogFragment().setOnDateSetListener(new CalendarDatePickerDialogFragment.OnDateSetListener() {
@Override
public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear, int dayOfMonth) {
if (mReminder.getDate() == null) {
mReminder.setDate(CalendarUtil.getNewInstanceZeroedCalendar());
}
mReminder.getDate().set(year, monthOfYear, dayOfMonth);
mDate.setText(mDateFormat.formatCalendar(mReminder.getDate()));
}
}).setPreselectedDate(mToday.get(Calendar.YEAR), mToday.get(Calendar.MONTH), mToday.get(Calendar.DAY_OF_MONTH)).setDateRange(new MonthAdapter.CalendarDay(mToday), null).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
mDatePicker.show(getFragmentManager(), "mDate");
}
});
mTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment().setOnTimeSetListener(new RadialTimePickerDialogFragment.OnTimeSetListener() {
@Override
public void onTimeSet(RadialTimePickerDialogFragment dialog, int hourOfDay, int minute) {
if (mReminder.getTime() == null) {
mReminder.setTime(new Time());
mReminder.getTime().setDisplayTimeFormat(SharedPreferenceUtil.getTimeFormat(getActivity()));
}
mReminder.getTime().setHour(hourOfDay);
mReminder.getTime().setMinute(minute);
mTime.setText(mReminder.getTime().toString());
}
}).setStartTime(12, 0).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
if (SharedPreferenceUtil.getTimeFormat(getActivity()).equals(TimeFormat.FORMAT_12H))
rtpd.setForced12hFormat();
else
rtpd.setForced24hFormat();
rtpd.show(getFragmentManager(), "mTime");
}
});
}
use of ve.com.abicelis.remindy.model.Time in project Remindy by abicelis.
the class EditRepeatingReminderFragment method setupDateAndTimePickers.
private void setupDateAndTimePickers() {
final Calendar mToday = Calendar.getInstance();
mDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDatePicker.setOnDateSetListener(new CalendarDatePickerDialogFragment.OnDateSetListener() {
@Override
public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear, int dayOfMonth) {
if (mReminder.getDate() == null) {
mReminder.setDate(CalendarUtil.getNewInstanceZeroedCalendar());
}
mReminder.getDate().set(year, monthOfYear, dayOfMonth);
mDate.setText(mDateFormat.formatCalendar(mReminder.getDate()));
trySetRepeatUntilDateValidDates();
}
}).setDateRange(new MonthAdapter.CalendarDay(mToday), null).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
mDatePicker.show(getFragmentManager(), "mDate");
}
});
mRepeatUntilDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mRepeatUntilDatePicker.setOnDateSetListener(new CalendarDatePickerDialogFragment.OnDateSetListener() {
@Override
public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear, int dayOfMonth) {
if (mReminder.getRepeatEndDate() == null) {
mReminder.setRepeatEndDate(CalendarUtil.getNewInstanceZeroedCalendar());
}
mReminder.getRepeatEndDate().set(year, monthOfYear, dayOfMonth);
mRepeatUntilDate.setText(mDateFormat.formatCalendar(mReminder.getRepeatEndDate()));
}
}).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
mRepeatUntilDatePicker.show(getFragmentManager(), "mRepeatUntilDate");
}
});
mTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mTimePicker = new RadialTimePickerDialogFragment().setOnTimeSetListener(new RadialTimePickerDialogFragment.OnTimeSetListener() {
@Override
public void onTimeSet(RadialTimePickerDialogFragment dialog, int hourOfDay, int minute) {
if (mReminder.getTime() == null) {
mReminder.setTime(new Time());
mReminder.getTime().setDisplayTimeFormat(SharedPreferenceUtil.getTimeFormat(getActivity()));
}
mReminder.getTime().setHour(hourOfDay);
mReminder.getTime().setMinute(minute);
mTime.setText(mReminder.getTime().toString());
}
}).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
if (SharedPreferenceUtil.getTimeFormat(getActivity()).equals(TimeFormat.FORMAT_12H))
mTimePicker.setForced12hFormat();
else
mTimePicker.setForced24hFormat();
mTimePicker.show(getFragmentManager(), "mTime");
}
});
mRepeatInterval.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new NumberPickerBuilder().setReference(0).setFragmentManager(getChildFragmentManager()).setTargetFragment(EditRepeatingReminderFragment.this).setStyleResId(R.style.BetterPickersDialogFragment_Light).setMaxNumber(new BigDecimal(99)).setMinNumber(new BigDecimal(1)).setDecimalVisibility(View.GONE).setPlusMinusVisibility(View.GONE).setOnDismissListener(new OnDialogDismissListener() {
@Override
public void onDialogDismiss(DialogInterface dialoginterface) {
trySetRepeatUntilDateValidDates();
}
}).show();
}
});
mRepeatEndForXEvents.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new NumberPickerBuilder().setReference(1).setFragmentManager(getChildFragmentManager()).setTargetFragment(EditRepeatingReminderFragment.this).setStyleResId(R.style.BetterPickersDialogFragment_Light).setMaxNumber(new BigDecimal(99)).setMinNumber(new BigDecimal(1)).setDecimalVisibility(View.GONE).setPlusMinusVisibility(View.GONE).show();
}
});
}
use of ve.com.abicelis.remindy.model.Time in project Remindy by abicelis.
the class RemindyDbHelper method insertMockData.
private void insertMockData(SQLiteDatabase sqLiteDatabase) {
String statement;
//Mock times
int time0600 = new Time(6, 0).getTimeInMinutes();
int time1259 = new Time(12, 59).getTimeInMinutes();
int time1800 = new Time(18, 0).getTimeInMinutes();
int time1930 = new Time(19, 30).getTimeInMinutes();
//Mock dates
Calendar cal = Calendar.getInstance();
// Set cal to be at midnight (start of day) today.
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.DAY_OF_MONTH, -7);
long dateLastWeek = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, +6);
long dateYesterday = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, +1);
long dateToday = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, +1);
long dateTomorrow = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, +1);
long dateIn2Days = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, +6);
long dateNextWeek = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, -8);
cal.add(Calendar.MONTH, +1);
long dateNextMonth = cal.getTimeInMillis();
cal.add(Calendar.MONTH, +2);
long dateNext3Months = cal.getTimeInMillis();
cal.add(Calendar.YEAR, +1);
long dateNextYear = cal.getTimeInMillis();
cal.add(Calendar.YEAR, +1);
long dateFuture = cal.getTimeInMillis();
//Insert mock Tasks Table
statement = "INSERT INTO " + RemindyContract.TaskTable.TABLE_NAME + " (" + RemindyContract.TaskTable._ID + COMMA_SEP + RemindyContract.TaskTable.COLUMN_NAME_STATUS.getName() + COMMA_SEP + RemindyContract.TaskTable.COLUMN_NAME_TITLE.getName() + COMMA_SEP + RemindyContract.TaskTable.COLUMN_NAME_DESCRIPTION.getName() + COMMA_SEP + RemindyContract.TaskTable.COLUMN_NAME_CATEGORY.getName() + COMMA_SEP + RemindyContract.TaskTable.COLUMN_NAME_REMINDER_TYPE.getName() + COMMA_SEP + RemindyContract.TaskTable.COLUMN_NAME_DONE_DATE.getName() + ") VALUES " + "(0, 'UNPROGRAMMED', 'Mock Task 0', 'Task 0 - No Reminder', 'PERSONAL', 'NONE', -1)," + "(1, 'UNPROGRAMMED', 'Mock Task 1', 'Task 1 - No Reminder', 'BUSINESS', 'NONE', -1)," + "(2, 'UNPROGRAMMED', 'Mock Task 2', 'Task 2 - No Reminder', 'PERSONAL', 'NONE', -1)," + "(3, 'UNPROGRAMMED', 'Mock Task 3', 'Task 3 - No Reminder', 'PERSONAL', 'NONE', -1)," + "(4, 'DONE', 'Mock Task 4', 'Task 4 - One-time DONE', 'PERSONAL', 'ONE_TIME', " + dateToday + ")," + "(5, 'DONE', 'Mock Task 5', 'Task 5 - One-time DONE', 'BUSINESS', 'ONE_TIME', " + dateYesterday + ")," + "(6, 'DONE', 'Mock Task 6', 'Task 6 - One-time DONE', 'PERSONAL', 'ONE_TIME', " + dateLastWeek + ")," + "(7, 'DONE', 'Mock Task 7', 'Task 7 - One-time DONE', 'BUSINESS', 'ONE_TIME', " + dateToday + ")," + "(8, 'DONE', 'Mock Task 8', 'Task 8 - One-time DONE', 'PERSONAL', 'ONE_TIME', " + dateYesterday + ")," + "(9, 'DONE', 'Mock Task 9', 'Task 9 - One-time DONE', 'BUSINESS', 'ONE_TIME', " + dateLastWeek + ")," + "(10, 'PROGRAMMED', 'Mock Task 10', 'Task 10 - One-time Reminder', 'REPAIRS', 'ONE_TIME', -1)," + "(11, 'PROGRAMMED', 'Mock Task 11', 'Task 11 - One-time Reminder', 'BUSINESS', 'ONE_TIME', -1)," + "(12, 'PROGRAMMED', 'Mock Task 12', 'Task 12 - One-time Reminder', 'HEALTH', 'ONE_TIME', -1)," + "(13, 'PROGRAMMED', 'Mock Task 13', 'Task 13 - One-time Reminder', 'SHOPPING', 'ONE_TIME', -1)," + "(14, 'PROGRAMMED', 'Mock Task 14', 'Task 14 - One-time Reminder', 'PERSONAL', 'ONE_TIME', -1)," + "(15, 'PROGRAMMED', 'Mock Task 15', 'Task 15 - One-time Reminder', 'HEALTH', 'ONE_TIME', -1)," + "(16, 'PROGRAMMED', 'Mock Task 16', 'Task 16 - Repeating Reminder', 'HEALTH', 'REPEATING', -1)," + "(17, 'PROGRAMMED', 'Mock Task 17', 'Task 17 - Repeating Reminder', 'BUSINESS', 'REPEATING', -1)," + "(18, 'PROGRAMMED', 'Mock Task 18', 'Task 18 - Repeating Reminder', 'SHOPPING', 'REPEATING', -1)," + "(19, 'PROGRAMMED', 'Mock Task 19', 'Task 19 - Location Reminder', 'REPAIRS', 'LOCATION_BASED', -1)," + "(20, 'PROGRAMMED', 'Mock Task 20', 'Task 20 - Location Reminder', 'HEALTH', 'LOCATION_BASED', -1)," + "(21, 'PROGRAMMED', 'Mock Task 21', 'Task 21 - Location Reminder', 'SHOPPING', 'LOCATION_BASED', -1)," + "(22, 'PROGRAMMED', 'Mock Task 22', 'Task 22 - Location Reminder', 'PERSONAL', 'LOCATION_BASED', -1);";
sqLiteDatabase.execSQL(statement);
//Insert mock Attachments
statement = "INSERT INTO " + RemindyContract.AttachmentTable.TABLE_NAME + " (" + RemindyContract.AttachmentTable._ID + COMMA_SEP + RemindyContract.AttachmentTable.COLUMN_NAME_TASK_FK.getName() + COMMA_SEP + RemindyContract.AttachmentTable.COLUMN_NAME_TYPE.getName() + COMMA_SEP + RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_TEXT.getName() + COMMA_SEP + RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_BLOB.getName() + ") VALUES " + "(0, 0, 'LINK', 'http://www.mocklinkTask1.com', '')," + "(1, 0, 'TEXT', 'Mock text', '')," + "(2, 1, 'LINK', 'http://www.mocklinkTask2.com', '')," + "(3, 2, 'LINK', 'http://www.mocklinkTask3.com', '')," + "(4, 2, 'LINK', 'http://www.mocklinkTask3.com', '')," + "(5, 4, 'TEXT', 'Mock text task 5', '')," + "(6, 5, 'TEXT', 'Mock text task 6', '')," + "(7, 6, 'TEXT', 'Mock text task 7', '')," + "(8, 7, 'LINK', 'http://www.mocklinkTask8.com', '')," + "(9, 7, 'TEXT', 'Mock text task 8', '')," + "(10, 8, 'LINK', 'http://www.mocklinkTask9.com', '')," + "(11, 9, 'LINK', 'http://www.mocklinkTask10.com', '');";
sqLiteDatabase.execSQL(statement);
//Insert mock One-time reminders
statement = "INSERT INTO " + RemindyContract.OneTimeReminderTable.TABLE_NAME + " (" + RemindyContract.OneTimeReminderTable._ID + COMMA_SEP + RemindyContract.OneTimeReminderTable.COLUMN_NAME_TASK_FK.getName() + COMMA_SEP + RemindyContract.OneTimeReminderTable.COLUMN_NAME_DATE.getName() + COMMA_SEP + RemindyContract.OneTimeReminderTable.COLUMN_NAME_TIME.getName() + ") VALUES " + "(0, 4, " + dateToday + ", " + time0600 + ")," + "(1, 5, " + dateTomorrow + ", " + time1259 + ")," + "(2, 6, " + dateNextWeek + ", " + time1930 + ")," + "(3, 7, " + dateNextMonth + ", " + time0600 + ")," + "(4, 8, " + dateNext3Months + ", " + time1800 + ")," + "(5, 9, " + dateNextYear + ", " + time0600 + ")," + "(6, 10, " + dateToday + ", " + time1259 + ")," + "(7, 11, " + dateTomorrow + ", " + time1930 + ")," + "(8, 12, " + dateIn2Days + ", " + time0600 + ")," + "(9, 13, " + dateNextMonth + ", " + time1930 + ")," + "(10, 14, " + dateNext3Months + ", " + time0600 + ")," + "(11, 15, " + dateFuture + ", " + time1800 + ");";
sqLiteDatabase.execSQL(statement);
//Insert mock Repeating reminders
statement = "INSERT INTO " + RemindyContract.RepeatingReminderTable.TABLE_NAME + " (" + RemindyContract.RepeatingReminderTable._ID + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_TASK_FK.getName() + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_DATE.getName() + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_TIME.getName() + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_TYPE.getName() + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_INTERVAL.getName() + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_END_TYPE.getName() + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_END_NUMBER_OF_EVENTS.getName() + COMMA_SEP + RemindyContract.RepeatingReminderTable.COLUMN_NAME_REPEAT_END_DATE.getName() + ") VALUES " + "(0, 16, " + dateYesterday + ", " + time0600 + ", 'MONTHLY', 2, 'FOREVER', -1, -1)," + "(1, 17, " + dateYesterday + ", " + time1800 + ", 'WEEKLY', 1, 'UNTIL_DATE', -1, " + dateToday + ")," + "(2, 18, " + dateLastWeek + ", " + time1930 + ", 'DAILY', 1, 'FOR_X_EVENTS', 2, -1);";
sqLiteDatabase.execSQL(statement);
//Insert mock Places
statement = "INSERT INTO " + RemindyContract.PlaceTable.TABLE_NAME + " (" + RemindyContract.PlaceTable._ID + COMMA_SEP + RemindyContract.PlaceTable.COLUMN_NAME_ALIAS.getName() + COMMA_SEP + RemindyContract.PlaceTable.COLUMN_NAME_ADDRESS.getName() + COMMA_SEP + RemindyContract.PlaceTable.COLUMN_NAME_LATITUDE.getName() + COMMA_SEP + RemindyContract.PlaceTable.COLUMN_NAME_LONGITUDE.getName() + COMMA_SEP + RemindyContract.PlaceTable.COLUMN_NAME_RADIUS.getName() + COMMA_SEP + RemindyContract.PlaceTable.COLUMN_NAME_IS_ONE_OFF.getName() + ") VALUES " + "('0', 'Home', 'Av. El Milagro, Edif. Los Canales', 10.6682603, -71.5940929, 500, 'false')," + "('1', 'Vicky', 'Urb La Paragua, Edif. Caicara V', 10.693981, -71.623274, 250, 'false')," + "('2', 'PizzaHut', 'PizzaHut address...', 10.693981, -71.633300, 2000, 'false')," + "('3', 'Andromeda Galaxy', 'Galaxy far away', 11.0000000, -72.000000, 2000, 'true');";
sqLiteDatabase.execSQL(statement);
//Insert mock Location-based reminders
statement = "INSERT INTO " + RemindyContract.LocationBasedReminderTable.TABLE_NAME + " (" + RemindyContract.LocationBasedReminderTable._ID + COMMA_SEP + RemindyContract.LocationBasedReminderTable.COLUMN_NAME_TASK_FK.getName() + COMMA_SEP + RemindyContract.LocationBasedReminderTable.COLUMN_NAME_PLACE_FK.getName() + COMMA_SEP + RemindyContract.LocationBasedReminderTable.COLUMN_NAME_TRIGGER_ENTERING.getName() + COMMA_SEP + RemindyContract.LocationBasedReminderTable.COLUMN_NAME_TRIGGER_EXITING.getName() + ") VALUES " + "(0, 19, 0, 'true', 'false')," + "(1, 20, 0, 'false', 'true')," + "(2, 21, 0, 'true', 'true')," + "(3, 22, 1, 'true', 'true');";
sqLiteDatabase.execSQL(statement);
}
Aggregations