From f5a7799924f135cfbb09139877a59209b2150108 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Thu, 2 Apr 2020 09:37:22 +0200 Subject: [PATCH] [API/Librus] Fix getting homework without attachments. --- .../data/synergia/LibrusSynergiaGetHomework.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/synergia/LibrusSynergiaGetHomework.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/synergia/LibrusSynergiaGetHomework.kt index 78abde37..32729a7e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/synergia/LibrusSynergiaGetHomework.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/synergia/LibrusSynergiaGetHomework.kt @@ -26,12 +26,15 @@ class LibrusSynergiaGetHomework(override val data: DataLibrus, event.attachmentIds = mutableListOf() event.attachmentNames = mutableListOf() - table[6].select("a").forEach { a -> - val attachmentId = a.attr("href").split('/') - .last().toLongOrNull() ?: return@forEach - val filename = a.text() - event.attachmentIds?.add(attachmentId) - event.attachmentNames?.add(filename) + + if (table.size > 6) { + table[6].select("a").forEach { a -> + val attachmentId = a.attr("href").split('/') + .last().toLongOrNull() ?: return@forEach + val filename = a.text() + event.attachmentIds?.add(attachmentId) + event.attachmentNames?.add(filename) + } } data.eventList.add(event)