fixed app crash (buffer overflow)

This commit is contained in:
Odweta
2024-03-08 18:15:25 +01:00
parent abcb2ab381
commit 6c8b0dc527
8 changed files with 155 additions and 12 deletions
@@ -58,7 +58,6 @@ class CalWeekFragment : Fragment() {
super.onPageSelected(position)
if (viewPager.isLaidOut) {
Vars.selectedDay = position
Log.d("debug", Vars.selectedDay.toString())
}
}
})
@@ -1,5 +1,6 @@
package com.odweta.solon
import android.util.Log
import org.json.JSONObject
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@@ -110,15 +111,17 @@ class Parsing {
}
for (subj in subjectJSONList) {
Log.d("debug", subj.toString())
// for each subject in one particular day
val subject = Subject()
val kind = subj.getJSONObject("hourKind").get("id")
val type = subj.getJSONObject("hourType").get("id")
if (
(type == "SUPLOVANA") ||
(type != "SUPLOVANI" && type != "ROZVRH")
) {
if (type == "SUPLOVANA") {
continue
}
if (type != "SUPLOVANI" && type != "ROZVRH") {
when (kind) {
"ZRUSENI_VYUKY_ROZVRH" -> {
subject.name = subj.get("title").toString()
@@ -232,14 +235,17 @@ class Parsing {
} else {
auxSubjects.add(subjects[i])
while ((auxSubjects[auxSubjects.size - 1].number.toInt() + 1).toString() != subjects[i + 1].number) {
var previous = auxSubjects[auxSubjects.size - 1].number.toInt() + 1
val next = subjects[i + 1].number.toInt()
while (previous < next) {
auxSubjects.add(
Subject.freeSubject(
(auxSubjects[auxSubjects.size - 1].number.toInt() + 1).toString(),
"",
""
previous.toString(),
subjects[i-1].end,
subjects[i+1].start
)
)
previous += 1
}
}
}