diff --git a/androidHyperskillApp/src/main/java/org/hyperskill/app/android/notification/local/DailyStudyReminderLocalNotificationDelegate.kt b/androidHyperskillApp/src/main/java/org/hyperskill/app/android/notification/local/DailyStudyReminderLocalNotificationDelegate.kt index 0958880d11..a66ca06e58 100644 --- a/androidHyperskillApp/src/main/java/org/hyperskill/app/android/notification/local/DailyStudyReminderLocalNotificationDelegate.kt +++ b/androidHyperskillApp/src/main/java/org/hyperskill/app/android/notification/local/DailyStudyReminderLocalNotificationDelegate.kt @@ -54,20 +54,19 @@ class DailyStudyReminderLocalNotificationDelegate( } override fun getNextScheduledAt(): Long? = - getNextScheduledAtInternal() - - fun scheduleDailyNotification() { - getNextScheduledAtInternal()?.let { scheduledAt -> - scheduleNotificationAt(scheduledAt) - } - } - - private fun getNextScheduledAtInternal(): Long? { if (!notificationInteractor.isDailyStudyRemindersEnabled()) { - return null + null + } else { + getNextScheduledAtInternal(notificationInteractor.getDailyStudyRemindersIntervalStartHour()) } - val hour = notificationInteractor.getDailyStudyRemindersIntervalStartHour() + fun scheduleDailyNotification( + selectedHour: Int = notificationInteractor.getDailyStudyRemindersIntervalStartHour() + ) { + scheduleNotificationAt(getNextScheduledAtInternal(selectedHour)) + } + + private fun getNextScheduledAtInternal(hour: Int): Long { val now = DateTimeHelper.nowUtc() val calendar = Calendar.getInstance() calendar.set(Calendar.HOUR_OF_DAY, hour) diff --git a/androidHyperskillApp/src/main/java/org/hyperskill/app/android/profile/view/fragment/ProfileFragment.kt b/androidHyperskillApp/src/main/java/org/hyperskill/app/android/profile/view/fragment/ProfileFragment.kt index ba063acd4d..b7ca810a10 100644 --- a/androidHyperskillApp/src/main/java/org/hyperskill/app/android/profile/view/fragment/ProfileFragment.kt +++ b/androidHyperskillApp/src/main/java/org/hyperskill/app/android/profile/view/fragment/ProfileFragment.kt @@ -256,7 +256,7 @@ class ProfileFragment : profileViewModel.onNewMessage( ProfileFeature.Message.DailyStudyRemindersIntervalStartHourChanged(chosenInterval) ) - platformNotificationComponent.dailyStudyReminderNotificationDelegate.scheduleDailyNotification() + platformNotificationComponent.dailyStudyReminderNotificationDelegate.scheduleDailyNotification(chosenInterval) } override fun onAction(action: ProfileFeature.Action.ViewAction) {