[API/Librus] Fix r() IndexOutOfBounds. Fix Descriptive grades NPE.

This commit is contained in:
Kuba Szczodrzyński 2019-09-25 21:40:03 +02:00
parent 3e6b0250d0
commit 554097fc7d

View File

@ -435,6 +435,10 @@ public class Librus implements EdziennikInterface {
callback.onProgress(PROGRESS_STEP);
index++;
}
if (index > targetEndpoints.size()) {
finish();
return;
}
d(TAG, "Called r("+type+", "+endpoint+"). Getting "+targetEndpoints.get(index));
switch (targetEndpoints.get(index)) {
case "Me":
@ -2409,7 +2413,15 @@ public class Librus implements EdziennikInterface {
long teacherId = grade.get("AddedBy").getAsJsonObject().get("Id").getAsLong();
int semester = grade.get("Semester").getAsInt();
long subjectId = grade.get("Subject").getAsJsonObject().get("Id").getAsLong();
String description = grade.get("Map").getAsString();
JsonElement map = grade.get("Map");
JsonElement realGrade = grade.get("RealGradeValue");
String description = "";
if (map != null) {
description = map.getAsString();
}
else if (realGrade != null) {
description = realGrade.getAsString();
}
long categoryId = -1;
JsonElement skillEl = grade.get("Skill");