Fix timetable widget crash when there are no lessons for the day (#1737)

This commit is contained in:
Mikołaj Pich 2021-12-31 09:40:15 +01:00 committed by GitHub
parent 210c3a0e28
commit ba02531aa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,13 +73,12 @@ class TimetableWidgetFactory(
updateTheme(appWidgetId)
lessons = getLessons(date, studentId)
if (date == LocalDate.now()) {
val todayLastLessonEndTimestamp =
lessons.maxOf { it.end }.toEpochSecond(ZoneOffset.UTC)
val todayLastLessonEndTimestamp = lessons.maxOfOrNull { it.end }
if (date == LocalDate.now() && todayLastLessonEndTimestamp != null) {
sharedPref.putLong(
getTodayLastLessonEndDateTimeWidgetKey(appWidgetId),
todayLastLessonEndTimestamp,
true
key = getTodayLastLessonEndDateTimeWidgetKey(appWidgetId),
value = todayLastLessonEndTimestamp.toEpochSecond(ZoneOffset.UTC),
sync = true
)
}
}