From b8c5925e82eb9d5d87159740362b131c2974f93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 26 Mar 2020 17:55:39 +0100 Subject: [PATCH] [API/Librus] Fix attendance NPE. --- .../api/edziennik/librus/data/api/LibrusApiAttendances.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAttendances.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAttendances.kt index 924e5e4d..3727788d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAttendances.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAttendances.kt @@ -13,6 +13,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Attendance import pl.szczodrzynski.edziennik.data.db.entity.Metadata import pl.szczodrzynski.edziennik.data.db.entity.SYNC_ALWAYS import pl.szczodrzynski.edziennik.utils.models.Date +import pl.szczodrzynski.edziennik.utils.models.Time class LibrusApiAttendances(override val data: DataLibrus, override val lastSync: Long?, @@ -45,7 +46,7 @@ class LibrusApiAttendances(override val data: DataLibrus, val typeObject = data.attendanceTypes[type] ?: null val topic = typeObject?.name ?: "" - val startTime = data.lessonRanges.get(lessonNo).startTime + val startTime = data.lessonRanges.get(lessonNo)?.startTime val lesson = if (lessonId != -1L) data.librusLessons.singleOrNull { it.lessonId == lessonId } @@ -59,7 +60,7 @@ class LibrusApiAttendances(override val data: DataLibrus, semester, topic, lessonDate, - startTime, + startTime ?: Time(0, 0, 0), typeObject?.type ?: Attendance.TYPE_CUSTOM )