make the app more tolerant about wrong API Data

This commit is contained in:
Jannik 2020-06-11 18:39:19 +02:00
parent 7779296345
commit 6c0624c793
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
2 changed files with 26 additions and 5 deletions

View File

@ -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) {
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)
}
}
}

View File

@ -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!!)