Canteen name will now be fetched as well; fixed an error that displayed the offers of the next day in CanteenFragment.kt

This commit is contained in:
denizk0461
2023-04-17 14:32:07 +02:00
parent 315f2f815a
commit 56cdc4c5ee
2 changed files with 9 additions and 3 deletions
@@ -28,7 +28,7 @@ class CanteenOfferPageAdapter(private var offers: List<CanteenOffer>, private va
layoutManager = LinearLayoutManager(holder.binding.root.context, LinearLayoutManager.VERTICAL, false)
val filtered = offers.filter { it.dateId == position + 1 }
val filtered = offers.filter { it.dateId == position }
adapter = CanteenOfferItemAdapter(filtered) // TODO check if empty
scheduleLayoutAnimation()
}
@@ -1,5 +1,6 @@
package com.denizk0461.studip.data
import android.util.Log
import com.denizk0461.studip.db.EventRepository
import com.denizk0461.studip.model.*
import org.jsoup.Jsoup
@@ -46,8 +47,10 @@ class StwParser {
dateId = 0
val doc = Jsoup.connect(url).get()
val t = doc.getElementsByClass("pane-title")[1].text()
repo.insert(OfferCanteen(canteenId, "TEMP")) // TODO canteen name
repo.insert(OfferCanteen(canteenId, t)) // TODO canteen name
Log.d("eek!3", t)
// STEP: get each day
doc.getElementsByClass("food-plan").forEach { dayPlan ->
@@ -126,7 +129,10 @@ class StwParser {
getElementsByAttributeValue("src", preference).isNotEmpty()
private fun Element.getFilteredText(): String {
var text = html().replace("&amp;", "&")
var text = html()
.replace("&amp;", "&")
.replace("&gt;", ">")
.replace("&lt;", "<")
while (text.contains("<sup>")) {
text = text.substring(0 until text.indexOf("<sup>")) + text.substring(text.indexOf("</sup>")+6 until text.length)