From 5e90e9aa71fea0777aff00f972efe93d182f4ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 28 Oct 2019 19:54:53 +0100 Subject: [PATCH] [APIv2/Mobidziennik] Make use of String.fixName() --- .../v2/mobidziennik/data/api/MobidziennikApiTimetable.kt | 6 +++--- .../api/v2/mobidziennik/data/api/MobidziennikApiUsers.kt | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) 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 62f760ab..ce938865 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 @@ -8,7 +8,7 @@ import pl.szczodrzynski.edziennik.api.v2.mobidziennik.DataMobidziennik import pl.szczodrzynski.edziennik.data.db.modules.lessons.Lesson import pl.szczodrzynski.edziennik.data.db.modules.lessons.LessonChange import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata -import pl.szczodrzynski.edziennik.fixWhiteSpaces +import pl.szczodrzynski.edziennik.fixName import pl.szczodrzynski.edziennik.singleOrNull class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List) { @@ -26,7 +26,7 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List) { data.subjectList.singleOrNull { it.longName == lesson[5] }?.let { lessonObject.subjectId = it.id } - data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixWhiteSpaces() }?.let { + data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixName() }?.let { lessonObject.teacherId = it.id } data.teamList.singleOrNull { it.name == lesson[8]+lesson[9] }?.let { @@ -52,7 +52,7 @@ class MobidziennikApiTimetable(val data: DataMobidziennik, rows: List) { data.subjectList.singleOrNull { it.longName == lesson[5] }?.let { lessonChange.subjectId = it.id } - data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixWhiteSpaces() }?.let { + data.teacherList.singleOrNull { it.fullNameLastFirst == (lesson[7]+" "+lesson[6]).fixName() }?.let { lessonChange.teacherId = it.id } data.teamList.singleOrNull { it.name == lesson[8]+lesson[9] }?.let { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiUsers.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiUsers.kt index 7b3fed51..1ef8619f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiUsers.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/mobidziennik/data/api/MobidziennikApiUsers.kt @@ -6,7 +6,7 @@ package pl.szczodrzynski.edziennik.api.v2.mobidziennik.data.api import pl.szczodrzynski.edziennik.api.v2.mobidziennik.DataMobidziennik import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher -import pl.szczodrzynski.edziennik.fixWhiteSpaces +import pl.szczodrzynski.edziennik.fixName class MobidziennikApiUsers(val data: DataMobidziennik, rows: List) { init { @@ -15,9 +15,12 @@ class MobidziennikApiUsers(val data: DataMobidziennik, rows: List) { continue val cols = row.split("|") + if (cols[1] != "*") + continue + val id = cols[0].toLong() - val name = cols[4].fixWhiteSpaces() - val surname = cols[5].fixWhiteSpaces() + val name = cols[4].fixName() + val surname = cols[5].fixName() data.teachersMap.put(id, "$surname $name") data.teacherList.put(id, Teacher(data.profileId, id, name, surname))