Browse Source

make the app more tolerant about wrong API Data

pull/46/head
Jannik 11 months ago
parent
commit
6c0624c793
Signed by: Seil0 GPG Key ID: E8459F3723C52C24
  1. 29
      app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt
  2. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

29
app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt

@ -37,6 +37,7 @@ import java.io.BufferedReader
import java.io.File
import java.io.FileReader
import java.util.*
import kotlin.Exception
import kotlin.collections.ArrayList
class CacheController(cont: Context) {
@ -168,10 +169,30 @@ class CacheController(cont: Context) {
* @param courseName the course name (e.g AI1)
*/
private fun readStartCache(courseName: String) {
readCoursesList(context)
readMensa(context)
readTimetable(courseName, 0, context)
readTimetable(courseName, 1, context)
try {
readCoursesList(context)
} catch (e : Exception) {
Log.e(className, "Error while reading the course list", e)
}
try {
readMensa(context)
} catch (e : Exception) {
Log.e(className, "Error while reading the mensa menu", e)
}
try {
readTimetable(courseName, 0, context)
} catch (e : Exception) {
Log.e(className, "Error while reading timetable week 0", e)
}
try {
readTimetable(courseName, 1, context)
} catch (e : Exception) {
Log.e(className, "Error while reading timetable week 1", e)
}
}
}

2
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -62,7 +62,7 @@ class TimeTableFragment : Fragment() {
// init actions
initActions()
if (timetables[0].timetable.days.isNotEmpty() && timetables[1].timetable.days.isNotEmpty()) {
if (timetables.size > 1 && timetables[0].timetable.days.isNotEmpty() && timetables[1].timetable.days.isNotEmpty()) {
initTimetable()
} else {
MaterialDialog(context!!)

Loading…
Cancel
Save