use of com.instructure.parentapp.receivers.AlarmReceiver in project instructure-android by instructure.
the class AssignmentFragment method cancelAlarm.
private void cancelAlarm() {
// cancel the alarm
AlarmReceiver alarmReceiver = new AlarmReceiver();
String subTitle = "";
if (mAssignment.getDueAt() != null) {
subTitle = getContext().getResources().getString(R.string.due) + " " + DateHelper.getDateTimeString(getContext(), mAssignment.getDueAt());
}
alarmReceiver.cancelAlarm(getContext(), mAssignment.getId(), mAssignment.getName(), subTitle);
// remove it from the database
if (mDatabaseHandler == null) {
mDatabaseHandler = new DatabaseHandler(getActivity());
}
try {
mDatabaseHandler.open();
int id = mDatabaseHandler.getRowIdByAssignmentId(mAssignment.getId());
int result = mDatabaseHandler.deleteAlarm(id);
mDatabaseHandler.close();
} catch (SQLException e) {
// couldn't delete the alarm, so it will remain in the database. But the actual
// alarm should have been canceled above.
}
}
use of com.instructure.parentapp.receivers.AlarmReceiver in project instructure-android by instructure.
the class AssignmentFragment method onTimeSet.
@Override
public void onTimeSet(int hourOfDay, int minute) {
mSetDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
mSetDate.set(Calendar.MINUTE, minute);
mAlarmDetails.setText(DateHelper.getShortDateTimeStringUniversal(getContext(), mSetDate.getTime()));
// save/update the alarm information
try {
mDatabaseHandler.open();
String subTitle;
if (mAssignment.getDueAt() != null) {
subTitle = getContext().getResources().getString(R.string.due) + " " + DateHelper.getShortDateTimeStringUniversal(getContext(), mAssignment.getDueAt());
} else {
subTitle = getContext().getResources().getString(R.string.no_due_date);
}
mDatabaseHandler.createAlarm(mSetDate.get(Calendar.YEAR), mSetDate.get(Calendar.MONTH), mSetDate.get(Calendar.DAY_OF_MONTH), mSetDate.get(Calendar.HOUR_OF_DAY), mSetDate.get(Calendar.MINUTE), mAssignment.getId(), mAssignment.getName(), subTitle);
mDatabaseHandler.close();
} catch (SQLException e) {
// couldn't save the alarm in the database, so stop here and don't actually create one. If the database
// doesn't have the alarm in it, the user will think that it didn't save
Toast.makeText(getContext(), getContext().getString(R.string.alarmNotSet), Toast.LENGTH_SHORT).show();
mTimePicker.dismiss();
return;
}
AlarmReceiver alarmReceiver = new AlarmReceiver();
String subTitle;
if (mAssignment.getDueAt() != null) {
subTitle = getContext().getResources().getString(R.string.due) + " " + DateHelper.getShortDateTimeStringUniversal(getContext(), mAssignment.getDueAt());
} else {
subTitle = getContext().getResources().getString(R.string.no_due_date);
}
alarmReceiver.setAlarm(getContext(), mSetDate, mAssignment.getId(), mAssignment.getName(), subTitle);
AnalyticUtils.trackButtonPressed(AnalyticUtils.REMINDER_ASSIGNMENT);
mTimePicker.dismiss();
}
use of com.instructure.parentapp.receivers.AlarmReceiver in project instructure-android by instructure.
the class EventFragment method onTimeSet.
@Override
public void onTimeSet(int hourOfDay, int minute) {
mSetDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
mSetDate.set(Calendar.MINUTE, minute);
mAlarmDetails.setText(DateHelper.getShortDateTimeStringUniversal(getContext(), mSetDate.getTime()));
// save/update the alarm information
try {
mDatabaseHandler.open();
String subTitle;
if (mScheduleItem.getStartAt() != null) {
subTitle = DateHelper.getShortDateTimeStringUniversal(getContext(), mScheduleItem.getStartAt());
} else {
subTitle = "";
}
mDatabaseHandler.createAlarm(mSetDate.get(Calendar.YEAR), mSetDate.get(Calendar.MONTH), mSetDate.get(Calendar.DAY_OF_MONTH), mSetDate.get(Calendar.HOUR_OF_DAY), mSetDate.get(Calendar.MINUTE), mScheduleItem.getId(), mScheduleItem.getTitle(), subTitle);
mDatabaseHandler.close();
} catch (SQLException e) {
// couldn't save the alarm in the database, so stop here and don't actually create one. If the database
// doesn't have the alarm in it, the user will think that it didn't save
Toast.makeText(getContext(), getContext().getString(R.string.alarmNotSet), Toast.LENGTH_SHORT).show();
mTimePicker.dismiss();
return;
}
AlarmReceiver alarmReceiver = new AlarmReceiver();
String subTitle;
if (mScheduleItem.getStartAt() != null) {
subTitle = DateHelper.getShortDateTimeStringUniversal(getContext(), mScheduleItem.getStartAt());
} else {
subTitle = "";
}
alarmReceiver.setAlarm(getContext(), mSetDate, mScheduleItem.getId(), mScheduleItem.getTitle(), subTitle);
AnalyticUtils.trackButtonPressed(AnalyticUtils.REMINDER_EVENT);
mTimePicker.dismiss();
}
use of com.instructure.parentapp.receivers.AlarmReceiver in project instructure-android by instructure.
the class EventFragment method cancelAlarm.
private void cancelAlarm() {
// cancel the alarm
AlarmReceiver alarmReceiver = new AlarmReceiver();
String subTitle = "";
if (mScheduleItem.getStartAt() != null) {
subTitle = DateHelper.getDateTimeString(getContext(), mScheduleItem.getStartAt());
}
alarmReceiver.cancelAlarm(getContext(), mScheduleItem.getId(), mScheduleItem.getTitle(), subTitle);
// remove it from the database
if (mDatabaseHandler == null) {
mDatabaseHandler = new DatabaseHandler(getActivity());
}
try {
mDatabaseHandler.open();
int id = mDatabaseHandler.getRowIdByAssignmentId(mScheduleItem.getId());
int result = mDatabaseHandler.deleteAlarm(id);
mDatabaseHandler.close();
} catch (SQLException e) {
// couldn't delete the alarm, so it will remain in the database. But the actual
// alarm should have been canceled above.
}
}
Aggregations