diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebTimetable.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebTimetable.kt index f6ee8b6e..b7f93607 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebTimetable.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/idziennik/data/web/IdziennikWebTimetable.kt @@ -28,7 +28,7 @@ class IdziennikWebTimetable(override val data: DataIdziennik, private const val TAG = "IdziennikWebTimetable" } - init { + init { data.profile?.also { profile -> val currentWeekStart = Week.getWeekStart() if (Date.getToday().weekDay > 4) { @@ -153,13 +153,15 @@ class IdziennikWebTimetable(override val data: DataIdziennik, dates.add(lessonDate.value) lessons.add(lessonObject) + val seen = profile.empty || lessonDate < Date.getToday() + if (lessonObject.type != Lesson.TYPE_NORMAL && lessonDate >= Date.getToday()) { data.metadataList.add(Metadata( profileId, Metadata.TYPE_LESSON_CHANGE, lessonObject.id, - profile?.empty ?: false, - profile?.empty ?: false, + seen, + seen, System.currentTimeMillis() )) } @@ -185,5 +187,5 @@ class IdziennikWebTimetable(override val data: DataIdziennik, data.setSyncNext(ENDPOINT_IDZIENNIK_WEB_TIMETABLE, SYNC_ALWAYS) onSuccess() } - } + }} } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/api/LibrusApiTimetables.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/api/LibrusApiTimetables.kt index e8d7991f..22813718 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/api/LibrusApiTimetables.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/api/LibrusApiTimetables.kt @@ -75,7 +75,7 @@ class LibrusApiTimetables(override val data: DataLibrus, } } - private fun parseLesson(lessonDate: Date, lesson: JsonObject) { + private fun parseLesson(lessonDate: Date, lesson: JsonObject) { data.profile?.also { profile -> val isSubstitution = lesson.getBoolean("IsSubstitutionClass") ?: false val isCancelled = lesson.getBoolean("IsCanceled") ?: false @@ -184,17 +184,19 @@ class LibrusApiTimetables(override val data: DataLibrus, } } - if (lessonObject.type != Lesson.TYPE_NORMAL && lessonDate >= Date.getToday()) { + val seen = profile.empty || lessonDate < Date.getToday() + + if (lessonObject.type != Lesson.TYPE_NORMAL) { data.metadataList.add( Metadata( - data.profileId, + profileId, Metadata.TYPE_LESSON_CHANGE, lessonObject.id, - data.profile?.empty ?: false, - data.profile?.empty ?: false, + seen, + seen, System.currentTimeMillis() )) } data.lessonNewList.add(lessonObject) - } + }} } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiTimetable.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiTimetable.kt index 68330cb4..bd970eb3 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiTimetable.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiTimetable.kt @@ -14,7 +14,7 @@ import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List) { - init { + init { data.profile?.also { profile -> val lessons = rows.filterNot { it.isEmpty() }.map { it.split("|") } val dataStart = Date.getToday() @@ -75,14 +75,16 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List) { } } - if (it.type != Lesson.TYPE_NORMAL && date >= Date.getToday()) { + val seen = profile.empty || date < Date.getToday() + + if (it.type != Lesson.TYPE_NORMAL) { data.metadataList.add( Metadata( data.profileId, Metadata.TYPE_LESSON_CHANGE, it.id, - data.profile?.empty ?: false, - data.profile?.empty ?: false, + seen, + seen, System.currentTimeMillis() )) } @@ -194,5 +196,5 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List) { } } }*/ - } + }} } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/api/VulcanApiTimetable.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/api/VulcanApiTimetable.kt index 5f5f72b2..080922e6 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/api/VulcanApiTimetable.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/api/VulcanApiTimetable.kt @@ -172,13 +172,15 @@ class VulcanApiTimetable(override val data: DataVulcan, val onSuccess: () -> Uni } } - if (type != Lesson.TYPE_NORMAL && lessonDate >= Date.getToday()) { + val seen = profile.empty || lessonDate < Date.getToday() + + if (type != Lesson.TYPE_NORMAL) { data.metadataList.add(Metadata( profileId, Metadata.TYPE_LESSON_CHANGE, id, - profile.empty, - profile.empty, + seen, + seen, System.currentTimeMillis() )) }