Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void startAlarm(Calendar c) {
- AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
- Intent intent = new Intent(getContext(), AlarmReceiver.class);
- PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(), 0, intent, 0);
- alarmManager.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pendingIntent);
- }
- mSaveAssessBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mSetAlert.isChecked()) {
- Calendar c = Calendar.getInstance();
- c.setTime(mAssessment.getGoalDate());
- startAlarm(c);
- }
- mAssessment.setAssessType(assessmentType);
- Intent myIntent = new Intent(getActivity(), AssessmentListActivity.class);
- startActivity(myIntent);
- }
- });
- private void startAlarm2(Calendar c2) {
- AlarmManager alarmManager2 = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
- Intent intent2 = new Intent(getContext(), AlarmReceiver.class);
- PendingIntent pendingIntent2 = PendingIntent.getBroadcast(getContext(), 0, intent2, 0);
- alarmManager2.set(AlarmManager.RTC_WAKEUP, c2.getTimeInMillis(), pendingIntent2);
- }
- submitStatusBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Calendar c2 = Calendar.getInstance();
- c2.setTime(mCourse.getStartDate());
- startAlarm2(c2);
- mCourse.setTitle(mTitleField.getText().toString());
- mCourse.setCourseStatus(mCourseStatus.getText().toString());
- //mCourse.setCourseStatus(radioButton.getText().toString());
- mCourse.setCourseNote(mOptonalNote.getText().toString());
- mCourse.setCourseMentorName(mMentorName.getText().toString());
- mCourse.setCourseMentorPhone(mMentorPhone.getText().toString());
- mCourse.setCourseMentorEmail(mMentorEmail.getText().toString());
- Intent myIntent = new Intent(getActivity(), CourseListActivity.class);
- startActivity(myIntent);
- }
- });
- public class AlarmReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- //first notification AssessmentFragment
- NotificationHelper notificationHelper = new NotificationHelper(context);
- NotificationCompat.Builder nb = notificationHelper.getChannelNotification();
- notificationHelper.getManager().notify(0, nb.build());
- //second notification CourseFragment
- NotificationHelper2 notificationHelper2 = new NotificationHelper2(context);
- NotificationCompat.Builder nb2 = notificationHelper2.getChannelNotification();
- notificationHelper2.getManager().notify(1, nb2.build());
- }
- }
- public NotificationCompat.Builder getChannelNotification() {
- return new NotificationCompat.Builder(getApplicationContext(), channelID)
- .setContentTitle("Assessment Goal today!")
- .setContentText("Your assessment Goal Date is today!")
- .setSmallIcon(R.drawable.alert);
- }
- public NotificationCompat.Builder getChannelNotification() {
- return new NotificationCompat.Builder(getApplicationContext(), channelID2)
- .setContentTitle("Course Starts today!")
- .setContentText("Your Course Start Date is today!")
- .setSmallIcon(R.drawable.alert);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement