forked from github/szkolny
[API/Librus] Add syncing grade comments
This commit is contained in:
parent
07d4616974
commit
1a74c2a174
@ -291,6 +291,7 @@ public class Librus implements EdziennikInterface {
|
||||
targetEndpoints.add("DescriptiveGrades");
|
||||
targetEndpoints.add("TextGrades");
|
||||
targetEndpoints.add("BehaviourGrades");
|
||||
targetEndpoints.add("GradesComments");
|
||||
|
||||
targetEndpoints.add("Events");
|
||||
targetEndpoints.add("CustomTypes");
|
||||
@ -364,6 +365,8 @@ public class Librus implements EdziennikInterface {
|
||||
targetEndpoints.add("DescriptiveGrades");
|
||||
targetEndpoints.add("TextGrades");
|
||||
targetEndpoints.add("BehaviourGrades");
|
||||
|
||||
targetEndpoints.add("GradesComments");
|
||||
break;
|
||||
case FEATURE_HOMEWORK:
|
||||
targetEndpoints.add("Homework");
|
||||
@ -509,6 +512,9 @@ public class Librus implements EdziennikInterface {
|
||||
case "TextGrades":
|
||||
getTextGrades();
|
||||
break;
|
||||
case "GradesComments":
|
||||
getGradesComments();
|
||||
break;
|
||||
case "BehaviourGrades":
|
||||
getBehaviourGrades();
|
||||
break;
|
||||
@ -1970,6 +1976,32 @@ public class Librus implements EdziennikInterface {
|
||||
});
|
||||
}
|
||||
|
||||
private void getGradesComments() {
|
||||
callback.onActionStarted(R.string.sync_action_syncing_grade_comments);
|
||||
apiRequest("Grades/Comments", data -> {
|
||||
if (data == null) {
|
||||
r("finish", "GradesComments");
|
||||
return;
|
||||
}
|
||||
|
||||
JsonArray comments = data.get("Comments").getAsJsonArray();
|
||||
for (JsonElement commentEl : comments) {
|
||||
JsonObject comment = commentEl.getAsJsonObject();
|
||||
long gradeId = comment.get("Grade").getAsJsonObject().get("Id").getAsLong();
|
||||
String text = comment.get("Text").getAsString();
|
||||
|
||||
for (Grade grade : gradeList) {
|
||||
if (grade.id == gradeId) {
|
||||
grade.description = text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r("finish", "GradesComments");
|
||||
});
|
||||
}
|
||||
|
||||
private void getPointGradesCategories() {
|
||||
if (!fullSync || !enablePointGrades) {
|
||||
// cancel every not-full sync; no need to download categories again
|
||||
|
@ -851,4 +851,6 @@
|
||||
<string name="messages_compose_menu_discard">Abort message</string>
|
||||
<string name="messages_compose_menu_save_draft">Save draft</string>
|
||||
<string name="messages_compose_menu_send">Send</string>
|
||||
<string name="sync_action_syncing_grade_comments">Getting grade comments</string>
|
||||
<string name="sync_action_syncing_school_free_days">Getting school free days</string>
|
||||
</resources>
|
||||
|
@ -908,4 +908,5 @@
|
||||
<string name="homework_tab_current">Aktualne</string>
|
||||
<string name="homework_tab_past">Minione</string>
|
||||
<string name="homework_no_data">Brak zadań domowych.</string>
|
||||
<string name="sync_action_syncing_grade_comments">Pobieranie komentarzy ocen</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user