Archived
small adjustments and bugfix; timeslot was always saved into the database longer than would be correct; for example, a course from 08:15 to 09:45 would have been saved as 08:15 to 11:45
This commit is contained in:
@@ -14,7 +14,7 @@ object DummyData {
|
||||
StudIPEvent(7, "Gesellschaft und Raum2", "Lossau, Mossig", "GW2 B1820", 4, 4, 2),
|
||||
)
|
||||
|
||||
val timeslotStartMap: Map<String, Int> = mapOf(
|
||||
private val timeslotStartMap: Map<String, Int> = mapOf(
|
||||
"6:00" to 0,
|
||||
"6:15" to 0,
|
||||
"8:00" to 1,
|
||||
@@ -31,7 +31,7 @@ object DummyData {
|
||||
"18:15" to 6,
|
||||
)
|
||||
|
||||
val timeslotEndMap: Map<String, Int> = mapOf(
|
||||
private val timeslotEndMap: Map<String, Int> = mapOf(
|
||||
"8:00" to 0,
|
||||
"7:45" to 0,
|
||||
"10:00" to 1,
|
||||
|
||||
@@ -9,7 +9,6 @@ class StudIPParser {
|
||||
fun parse(html: String, insert: (events: List<StudIPEvent>) -> Unit) {
|
||||
var id = 0
|
||||
val doc = Jsoup.parse(html)
|
||||
Log.d("HELLO2", "doc: $doc")
|
||||
val newEvents = mutableListOf<StudIPEvent>()
|
||||
val columns = arrayOf(
|
||||
doc.getElementById("calendar_view_1_column_0"),
|
||||
@@ -18,16 +17,14 @@ class StudIPParser {
|
||||
doc.getElementById("calendar_view_1_column_3"),
|
||||
doc.getElementById("calendar_view_1_column_4"),
|
||||
)
|
||||
Log.d("HELLO2", "days found: ${columns.size}, element 1: ${columns[0]}")
|
||||
columns.forEachIndexed { index, element ->
|
||||
element?.getElementsByClass("schedule_entry")?.forEachIndexed { entryIndex, entry ->
|
||||
Log.d("HELLO2", "element - $entryIndex - found: $entry")
|
||||
val entryHeader = entry.getElementsByTag("dt")[0].text()
|
||||
val delimiter = entryHeader.lastIndexOf('(')
|
||||
val parsedTitle = entryHeader.substring(0 until delimiter)
|
||||
val parsedLecturers = entryHeader.substring(delimiter + 1 until entryHeader.length - 1)
|
||||
|
||||
val entryInfos = entry.getElementsByTag("dd")[0].text().split(", ")
|
||||
val entryInfos = entry.getElementsByTag("dd")[0].text().split(", ", limit = 2)
|
||||
val timeSlot = DummyData.parseTimeslot(entryInfos[0])
|
||||
|
||||
val event = StudIPEvent(
|
||||
@@ -41,7 +38,6 @@ class StudIPParser {
|
||||
)
|
||||
newEvents.add(event)
|
||||
id += 1
|
||||
Log.d("HELLO2", event.toString())
|
||||
}
|
||||
}
|
||||
insert(newEvents)
|
||||
|
||||
@@ -16,22 +16,10 @@ data class StudIPEvent(
|
||||
val timeslotEnd: Int, // 1 = 09:45 etc.
|
||||
) {
|
||||
|
||||
// constructor(
|
||||
// val title: String,
|
||||
// val lecturer: String,
|
||||
// val room: String,
|
||||
// val day: Int,
|
||||
// val
|
||||
// ) : this(title, lecturer, room, day, 1, 1)
|
||||
|
||||
@Ignore private val timeSlotStartTimes: List<String> = listOf("06:15", "08:15", "10:15", "12:15", "14:15", "16:15", "18:15")
|
||||
@Ignore private val timeSlotEndTimes: List<String> = listOf("07:45", "09:45", "11:45", "13:45", "15:45", "17:45", "19:45")
|
||||
|
||||
fun timeslot(): String {
|
||||
Log.d("HELLO3", title)
|
||||
Log.d("HELLO3", "s $timeslotStart st $timeslotEnd")
|
||||
return "${timeSlotStartTimes[timeslotStart]} – ${timeSlotEndTimes[timeslotEnd]}"
|
||||
}
|
||||
fun timeslot(): String = "${timeSlotStartTimes[timeslotStart]} – ${timeSlotEndTimes[timeslotEnd]}"
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
|
||||
Reference in New Issue
Block a user