From 37e57d2f733002d97431fcc82b2baa886cdfaa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 25 Sep 2019 21:48:28 +0200 Subject: [PATCH] [API/Librus] Fix timetable with no HourFrom and HourTo. --- .../szczodrzynski/edziennik/api/Librus.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java index ca231ebf..d431dae2 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Librus.java @@ -1671,11 +1671,32 @@ public class Librus implements EdziennikInterface { continue; } + Time startTime = null; + Time endTime = null; + try { + startTime = Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourFrom" : "HourFrom").getAsString()); + endTime = Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourTo" : "HourTo").getAsString()); + } + catch (Exception ignore) { + try { + JsonElement lessonNo; + if (!((lessonNo = lesson.get("LessonNo")) instanceof JsonNull)) { + Pair timePair = lessonRanges.get(strToInt(lessonNo.getAsString())); + if (timePair != null) { + startTime = timePair.first; + endTime = timePair.second; + } + } + } + catch (Exception ignore2) { } + } + + Lesson lessonObject = new Lesson( profileId, lesson.get("DayNo").getAsInt() - 1, - Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourFrom" : "HourFrom").getAsString()), - Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourTo" : "HourTo").getAsString()) + startTime, + endTime ); JsonElement subject; @@ -1720,7 +1741,7 @@ public class Librus implements EdziennikInterface { r("finish", "Substitutions"); return; } - + JsonArray substitutions = data.get("Substitutions").getAsJsonArray(); try { List ignoreList = new ArrayList<>();