[API/Librus] Fix timetable with no HourFrom and HourTo.

This commit is contained in:
Kuba Szczodrzyński 2019-09-25 21:48:28 +02:00
parent 554097fc7d
commit 37e57d2f73

View File

@ -1671,11 +1671,32 @@ public class Librus implements EdziennikInterface {
continue; 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<Time, Time> timePair = lessonRanges.get(strToInt(lessonNo.getAsString()));
if (timePair != null) {
startTime = timePair.first;
endTime = timePair.second;
}
}
}
catch (Exception ignore2) { }
}
Lesson lessonObject = new Lesson( Lesson lessonObject = new Lesson(
profileId, profileId,
lesson.get("DayNo").getAsInt() - 1, lesson.get("DayNo").getAsInt() - 1,
Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourFrom" : "HourFrom").getAsString()), startTime,
Time.fromH_m(lesson.get(substitution && !cancelled ? "OrgHourTo" : "HourTo").getAsString()) endTime
); );
JsonElement subject; JsonElement subject;
@ -1720,7 +1741,7 @@ public class Librus implements EdziennikInterface {
r("finish", "Substitutions"); r("finish", "Substitutions");
return; return;
} }
JsonArray substitutions = data.get("Substitutions").getAsJsonArray(); JsonArray substitutions = data.get("Substitutions").getAsJsonArray();
try { try {
List<Long> ignoreList = new ArrayList<>(); List<Long> ignoreList = new ArrayList<>();