[APIv2/Librus] Show starting points only when greater than 0.

This commit is contained in:
Kacper Ziubryniewicz 2019-12-22 22:22:46 +01:00
parent fe40ab0ab4
commit 8f8eb64364

View File

@ -26,53 +26,57 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
init { data.profile?.let { profile -> init { data.profile?.let { profile ->
apiGet(TAG, "BehaviourGrades/Points") { json -> apiGet(TAG, "BehaviourGrades/Points") { json ->
val semester1StartGradeObject = Grade( if (data.startPointsSemester1 > 0) {
profileId, val semester1StartGradeObject = Grade(
-101, profileId,
data.app.getString(R.string.grade_start_points), -101,
0xffbdbdbd.toInt(), data.app.getString(R.string.grade_start_points),
data.app.getString(R.string.grade_start_points_format, 1), 0xffbdbdbd.toInt(),
nameFormat.format(data.startPointsSemester1), data.app.getString(R.string.grade_start_points_format, 1),
data.startPointsSemester1.toFloat(), nameFormat.format(data.startPointsSemester1),
-1f, data.startPointsSemester1.toFloat(),
1, -1f,
-1, 1,
1 -1,
).apply { type = Grade.TYPE_BEHAVIOUR } 1
).apply { type = Grade.TYPE_BEHAVIOUR }
data.gradeList.add(semester1StartGradeObject) data.gradeList.add(semester1StartGradeObject)
data.metadataList.add(Metadata( data.metadataList.add(Metadata(
profileId, profileId,
Metadata.TYPE_GRADE, Metadata.TYPE_GRADE,
semester1StartGradeObject.id, semester1StartGradeObject.id,
true, true,
true, true,
profile.getSemesterStart(1).inMillis profile.getSemesterStart(1).inMillis
)) ))
}
val semester2StartGradeObject = Grade( if (data.startPointsSemester2 > 0) {
profileId, val semester2StartGradeObject = Grade(
-102, profileId,
data.app.getString(R.string.grade_start_points), -102,
0xffbdbdbd.toInt(), data.app.getString(R.string.grade_start_points),
data.app.getString(R.string.grade_start_points_format, 2), 0xffbdbdbd.toInt(),
nameFormat.format(data.startPointsSemester2), data.app.getString(R.string.grade_start_points_format, 2),
data.startPointsSemester2.toFloat(), nameFormat.format(data.startPointsSemester2),
-1f, data.startPointsSemester2.toFloat(),
2, -1f,
-1, 2,
1 -1,
).apply { type = Grade.TYPE_BEHAVIOUR } 1
).apply { type = Grade.TYPE_BEHAVIOUR }
data.gradeList.add(semester2StartGradeObject) data.gradeList.add(semester2StartGradeObject)
data.metadataList.add(Metadata( data.metadataList.add(Metadata(
profileId, profileId,
Metadata.TYPE_GRADE, Metadata.TYPE_GRADE,
semester2StartGradeObject.id, semester2StartGradeObject.id,
true, true,
true, true,
profile.getSemesterStart(2).inMillis profile.getSemesterStart(2).inMillis
)) ))
}
json.getJsonArray("Grades")?.asJsonObjectList()?.forEach { grade -> json.getJsonArray("Grades")?.asJsonObjectList()?.forEach { grade ->
val id = grade.getLong("Id") ?: return@forEach val id = grade.getLong("Id") ?: return@forEach