make the app more tolerant about wrong API Data
This commit is contained in:
parent
7779296345
commit
6c0624c793
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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…
Reference in New Issue