mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[API/Mobidziennik] Fix getting recipient list.
This commit is contained in:
parent
5c84086f42
commit
b31039ecd9
@ -12,6 +12,10 @@ object Regexes {
|
|||||||
"""color: (\w+);?""".toRegex()
|
"""color: (\w+);?""".toRegex()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val NOT_DIGITS by lazy {
|
||||||
|
"""[^0-9]""".toRegex()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val MOBIDZIENNIK_GRADES_SUBJECT_NAME by lazy {
|
val MOBIDZIENNIK_GRADES_SUBJECT_NAME by lazy {
|
||||||
|
@ -56,20 +56,21 @@ class MobidziennikWebGetRecipientList(override val data: DataMobidziennik,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun processRecipient(listType: Int, listName: String, recipient: JsonObject) {
|
private fun processRecipient(listType: Int, listName: String, recipient: JsonObject) {
|
||||||
val id = recipient.getLong("id") ?: -1
|
val id = recipient.getString("id") ?: return
|
||||||
|
val idLong = id.replace(Regexes.NOT_DIGITS, "").toLongOrNull() ?: return
|
||||||
// get teacher by ID or create it
|
// get teacher by ID or create it
|
||||||
val teacher = data.teacherList[id] ?: Teacher(data.profileId, id).apply {
|
val teacher = data.teacherList[idLong] ?: Teacher(data.profileId, idLong).apply {
|
||||||
val fullName = recipient.getString("nazwa")?.fixName()
|
val fullName = recipient.getString("nazwa")?.fixName()
|
||||||
name = fullName ?: ""
|
name = fullName ?: ""
|
||||||
fullName?.splitName()?.let {
|
fullName?.splitName()?.let {
|
||||||
name = it.second
|
name = it.second
|
||||||
surname = it.first
|
surname = it.first
|
||||||
}
|
}
|
||||||
data.teacherList[id] = this
|
data.teacherList[idLong] = this
|
||||||
}
|
}
|
||||||
|
|
||||||
teacher.apply {
|
teacher.apply {
|
||||||
loginId = id.toString()
|
loginId = id
|
||||||
when (listType) {
|
when (listType) {
|
||||||
1 -> setTeacherType(Teacher.TYPE_PRINCIPAL)
|
1 -> setTeacherType(Teacher.TYPE_PRINCIPAL)
|
||||||
2 -> setTeacherType(Teacher.TYPE_TEACHER)
|
2 -> setTeacherType(Teacher.TYPE_TEACHER)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user