Moved the fetching task to a separate activity; changed the time attributes in StudIPEvent.kt to strings

This commit is contained in:
denizk0461
2023-04-12 18:58:10 +02:00
parent 4f78eb8373
commit d55a304cec
11 changed files with 131 additions and 29 deletions
@@ -4,15 +4,15 @@ import com.denizk0461.studip.model.StudIPEvent
object Misc {
val events: Array<StudIPEvent> = arrayOf(
StudIPEvent(1, "Literatures", "Nittel", "MZH 1380/1400", 0, 3, 1),
StudIPEvent(2, "Linguistics", "Du Bois", "SFG 1020", 1, 1, 1),
StudIPEvent(3, "System Erde", "Zolitschka, Labuhn-Deroubaix", "GW2 B1410", 1, 3, 1),
StudIPEvent(4, "Key Moments", "Esders-Angermund", "GW2 B2890", 2, 2, 1),
StudIPEvent(5, "ULS-1", "Herrmann", "GW2 B2890", 2, 3, 1),
StudIPEvent(6, "Gesellschaft und Raum", "Lossau, Mossig", "GW2 B1820", 3, 1, 1),
StudIPEvent(7, "Gesellschaft und Raum2", "Lossau, Mossig", "GW2 B1820", 4, 4, 2),
)
// val events: Array<StudIPEvent> = arrayOf(
// StudIPEvent(1, "Literatures", "Nittel", "MZH 1380/1400", 0, 3, 1),
// StudIPEvent(2, "Linguistics", "Du Bois", "SFG 1020", 1, 1, 1),
// StudIPEvent(3, "System Erde", "Zolitschka, Labuhn-Deroubaix", "GW2 B1410", 1, 3, 1),
// StudIPEvent(4, "Key Moments", "Esders-Angermund", "GW2 B2890", 2, 2, 1),
// StudIPEvent(5, "ULS-1", "Herrmann", "GW2 B2890", 2, 3, 1),
// StudIPEvent(6, "Gesellschaft und Raum", "Lossau, Mossig", "GW2 B1820", 3, 1, 1),
// StudIPEvent(7, "Gesellschaft und Raum2", "Lossau, Mossig", "GW2 B1820", 4, 4, 2),
// )
private val timeslotStartMap: Map<String, Int> = mapOf(
"6:00" to 0,
@@ -9,7 +9,7 @@ class StudIPParser {
var id = 0
val doc = Jsoup.parse(html)
val newEvents = mutableListOf<StudIPEvent>()
val columns = arrayOf(
val columns = arrayOf( // TODO THIS NEEDS TO BE DYNAMIC!
doc.getElementById("calendar_view_1_column_0"),
doc.getElementById("calendar_view_1_column_1"),
doc.getElementById("calendar_view_1_column_2"),
@@ -24,7 +24,8 @@ class StudIPParser {
val parsedLecturers = entryHeader.substring(delimiter + 1 until entryHeader.length - 1)
val entryInfos = entry.getElementsByTag("dd")[0].text().split(", ", limit = 2)
val timeSlot = Misc.parseTimeslot(entryInfos[0])
// val timeSlot = Misc.parseTimeslot(entryInfos[0])
val timeSlot = entryInfos[0].split(" - ")
val event = StudIPEvent(
id = id,
@@ -32,8 +33,8 @@ class StudIPParser {
lecturer = parsedLecturers,
room = entryInfos[1],
day = index,
timeslotStart = timeSlot.first,
timeslotEnd = timeSlot.second,
timeslotStart = timeSlot[0],
timeslotEnd = timeSlot[1],
)
newEvents.add(event)
id += 1