use HashMap insted of ArrayList to store the timetables
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-06 23:07:23 +02:00
parent fe72c02562
commit f9029bf1c3
4 changed files with 29 additions and 40 deletions

View File

@ -36,17 +36,15 @@ class CourseListParser {
* @param courseListURL the url to the course list page
* @return a ArrayList<Course> with all courses or null if the request was not successful
*/
fun getCourseLinks(courseListURL: String): ArrayList<Course>? {
val courseLinkList = ArrayList<Course>()
fun getCourseLinks(courseListURL: String): HashMap<String, Course>? {
val courseLinkList = HashMap<String, Course>()
try {
val courseHTML = Jsoup.connect(courseListURL).get()
courseHTML.select("ul.index-group").select("li.Class").select("a[href]").forEachIndexed { _, element ->
courseLinkList.add(
Course(
element.text(),
element.attr("href").replace("http", "https")
)
courseLinkList[element.text()] = Course(
element.text(),
element.attr("href").replace("http", "https")
)
}
} catch (ex: SocketTimeoutException) {