diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebAnnouncements.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebAnnouncements.kt index c0c215c6..a0db8c1b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebAnnouncements.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebAnnouncements.kt @@ -14,7 +14,6 @@ import pl.szczodrzynski.edziennik.data.db.modules.announcements.Announcement import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata import pl.szczodrzynski.edziennik.get -import pl.szczodrzynski.edziennik.splitName import pl.szczodrzynski.edziennik.utils.models.Date class EdudziennikWebAnnouncements(override val data: DataEdudziennik, @@ -37,9 +36,7 @@ class EdudziennikWebAnnouncements(override val data: DataEdudziennik, val subject = titleElement.text() val teacherName = announcementElement.child(1).text() - val teacher = teacherName.splitName()?.let { (teacherFirstName, teacherLastName) -> - data.getTeacher(teacherFirstName, teacherLastName) - } ?: return@forEach + val teacher = data.getTeacherByFirstLast(teacherName) val dateString = announcementElement.getElementsByClass("datetime").first().text() val startDate = Date.fromY_m_d(dateString) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebGrades.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebGrades.kt index aea52f0f..ad87b69c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebGrades.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebGrades.kt @@ -82,8 +82,8 @@ class EdudziennikWebGrades(override val data: DataEdudziennik, val description = columnName + if (comment.isNotBlank()) " - $comment" else "" - val (teacherLastName, teacherFirstName) = info.child(1).text().split(' ') - val teacher = data.getTeacher(teacherFirstName, teacherLastName) + val teacherName = info.child(1).text() + val teacher = data.getTeacherByLastFirst(teacherName) val addedDate = info.child(2).text().split(' ').let { val day = it[0].toInt() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebHomework.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebHomework.kt index af846615..4bfff783 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebHomework.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebHomework.kt @@ -16,7 +16,6 @@ import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS import pl.szczodrzynski.edziennik.data.db.modules.events.Event import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata import pl.szczodrzynski.edziennik.get -import pl.szczodrzynski.edziennik.splitName import pl.szczodrzynski.edziennik.utils.models.Date class EdudziennikWebHomework(override val data: DataEdudziennik, @@ -46,9 +45,7 @@ class EdudziennikWebHomework(override val data: DataEdudziennik, val startTime = lessons.firstOrNull { it.subjectId == subject.id }?.displayStartTime val teacherName = homeworkElement.child(2).text() - val teacher = teacherName.splitName()?.let { (teacherFirstName, teacherLastName) -> - data.getTeacher(teacherFirstName, teacherLastName) - } ?: return@forEach + val teacher = data.getTeacherByFirstLast(teacherName) val topic = homeworkElement.child(4).text() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebTimetable.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebTimetable.kt index 1c90578f..79879fc9 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebTimetable.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/edudziennik/data/web/EdudziennikWebTimetable.kt @@ -20,7 +20,6 @@ import pl.szczodrzynski.edziennik.data.db.modules.timetable.Lesson import pl.szczodrzynski.edziennik.get import pl.szczodrzynski.edziennik.getString import pl.szczodrzynski.edziennik.singleOrNull -import pl.szczodrzynski.edziennik.splitName import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Time @@ -108,10 +107,8 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik, val teacherElement = info[1].child(0) val teacherLongId = EDUDZIENNIK_TEACHER_ID.find(teacherElement.attr("href"))?.get(1) val teacherName = teacherElement.text().trim() - teacherName.splitName()?.let { (teacherLastName, teacherFirstName) -> - data.getTeacher(teacherFirstName, teacherLastName, teacherLongId) - }?.id ?: -1 - } else -1 + data.getTeacherByLastFirst(teacherName, teacherLongId).id + } else null val lessonObject = Lesson(profileId, -1).also { it.type = type @@ -121,6 +118,7 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik, it.endTime = endTime it.subjectId = subject.id it.teacherId = teacherId + it.teamId = data.teamClass?.id it.id = it.buildId() }