예제 #1
0
        public override void OnReceive(Context context, Intent intent)
        {
            var notificationManager = context.GetSystemService(Context.NotificationService) as NotificationManager;

            notificationManager?.CancelAll();

            var exerciseName     = intent.GetStringExtra(Constants.ExerciseName);
            var exerciseQuantity = intent.GetIntExtra(Constants.ExerciseQuantity, -1);

            if (!string.IsNullOrEmpty(exerciseName) && exerciseQuantity > 0)
            {
                _data.MarkExerciseNotified(exerciseName, -1 * exerciseQuantity);
            }

            var nextExercise = _data.GetNextEnabledExercise();

            UserNotification.CreateExerciseNotification(_data, context, nextExercise);
        }
예제 #2
0
        public override void OnReceive(Context context, Intent intent)
        {
            var preferences = context.GetSharedPreferences(Constants.SharedPreferencesKey, FileCreationMode.Private);

            if (!preferences.GetBoolean(Constants.ServiceIsStartedKey, false))
            {
                return;
            }

            var exerciseSchedule = _data.GetExerciseSchedule();
            var now = DateTime.Now.TimeOfDay;

            if (now > exerciseSchedule.StartTime.TimeOfDay && now < exerciseSchedule.EndTime.TimeOfDay)
            {
                UserNotification.CreateExerciseNotification(_data, context);
            }

            var nextAlarmTime = ExerciseServiceManager.SetNextAlarm(context, exerciseSchedule);

            if (nextAlarmTime.Date > DateTime.Now.Date && PreferenceManager.GetDefaultSharedPreferences(context).GetBoolean(context.Resources.GetString(Resource.String.CheckHistoryReminderKey), true))
            {
                UserNotification.CreateHistoryReminderNotification(context);
            }
        }