Browse Source

update TCoRAPIController to API version 1.2.0

pull/46/head
Jannik 11 months ago
parent
commit
18ca435764
Signed by: Seil0 GPG Key ID: E8459F3723C52C24
  1. 10
      app/src/main/java/org/mosad/seil0/projectlaogai/controller/TCoRAPIController.kt

10
app/src/main/java/org/mosad/seil0/projectlaogai/controller/TCoRAPIController.kt

@ -116,7 +116,7 @@ class TCoRAPIController {
* Read the json object from tcor api and write it as file (cache).
*/
fun getTimetable(courseName: String, week: Int, context: Context): Job {
val url = URL("$tcorBaseURL/timetable?courseName=$courseName&week=$week")
val url = URL("$tcorBaseURL/timetable?course=$courseName&week=$week")
val file = File(context.filesDir, "timetable-$courseName-$week.json")
return GlobalScope.launch(Dispatchers.IO) {
@ -150,7 +150,7 @@ class TCoRAPIController {
* @param week the week to look up
*/
fun getLessonSubjectListAsync(courseName: String, week: Int): Deferred<ArrayList<String>> {
val url = URL("$tcorBaseURL/lessonSubjectList?courseName=$courseName&week=$week")
val url = URL("$tcorBaseURL/subjectList?course=$courseName&week=$week")
return GlobalScope.async {
Gson().fromJson(url.readText(), ArrayList<String>()::class.java)
@ -160,11 +160,11 @@ class TCoRAPIController {
/**
* Get all occurrences of a lesson for a course at one week
* @param courseName the course name
* @param lessonSubject the subject to search for
* @param subject the subject to search for
* @param week the week to look up
*/
fun getLessonsAsync(courseName: String, lessonSubject: String, week: Int): Deferred<ArrayList<Lesson>> {
val url = URL("$tcorBaseURL/lessons?courseName=$courseName&lessonSubject=$lessonSubject&week=$week")
fun getLessonsAsync(courseName: String, subject: String, week: Int): Deferred<ArrayList<Lesson>> {
val url = URL("$tcorBaseURL/lessons?course=$courseName&subject=$subject&week=$week")
return GlobalScope.async {
Gson().fromJson(url.readText(), ArrayList<Lesson>()::class.java)

Loading…
Cancel
Save