use of com.instructure.parentapp.models.CalendarWrapper in project instructure-android by instructure.
the class BootReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
// set alarms here
DatabaseHandler mDatabaseHandler = new DatabaseHandler(context);
try {
mDatabaseHandler.open();
ArrayList<CalendarWrapper> calendars = mDatabaseHandler.getAllAlarms();
if (calendars != null) {
for (CalendarWrapper wrapper : calendars) {
alarm.setAlarm(context, wrapper.getCalendar(), wrapper.getAssignmentId(), wrapper.getTitle(), wrapper.getSubTitle());
}
}
mDatabaseHandler.close();
} catch (SQLException e) {
// do nothing
}
}
}
use of com.instructure.parentapp.models.CalendarWrapper in project instructure-android by instructure.
the class DatabaseHandler method getAllAlarms.
public ArrayList<CalendarWrapper> getAllAlarms() {
String[] columns = new String[] { KEY_ROWID, KEY_YEAR, KEY_MONTH, KEY_DAY, KEY_HOUR, KEY_MINUTE, KEY_ASSIGNMENT_ID, KEY_TITLE, KEY_SUBTITLE };
ArrayList<CalendarWrapper> calendars = new ArrayList<>();
Cursor cursor = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
if (cursor.getCount() == 0) {
return null;
}
while (!cursor.isAfterLast()) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, cursor.getInt(1));
calendar.set(Calendar.MONTH, cursor.getInt(2));
calendar.set(Calendar.DAY_OF_MONTH, cursor.getInt(3));
calendar.set(Calendar.HOUR_OF_DAY, cursor.getInt(4));
calendar.set(Calendar.MINUTE, cursor.getInt(5));
long assignmentId = cursor.getInt(6);
String title = cursor.getString(7);
String subTitle = cursor.getString(8);
// only add the calendar if the date is after today
Calendar today = Calendar.getInstance();
if (calendar.after(today)) {
calendars.add(new CalendarWrapper(calendar, assignmentId, title, subTitle));
}
cursor.moveToNext();
}
cursor.close();
return calendars;
}
return null;
}
Aggregations