Archived
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:
@@ -28,7 +28,7 @@ class CanteenOfferPageAdapter(private var offers: List<CanteenOffer>, private va
|
|||||||
|
|
||||||
layoutManager = LinearLayoutManager(holder.binding.root.context, LinearLayoutManager.VERTICAL, false)
|
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
|
adapter = CanteenOfferItemAdapter(filtered) // TODO check if empty
|
||||||
scheduleLayoutAnimation()
|
scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.denizk0461.studip.data
|
package com.denizk0461.studip.data
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.denizk0461.studip.db.EventRepository
|
import com.denizk0461.studip.db.EventRepository
|
||||||
import com.denizk0461.studip.model.*
|
import com.denizk0461.studip.model.*
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
@@ -46,8 +47,10 @@ class StwParser {
|
|||||||
dateId = 0
|
dateId = 0
|
||||||
|
|
||||||
val doc = Jsoup.connect(url).get()
|
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
|
// STEP: get each day
|
||||||
doc.getElementsByClass("food-plan").forEach { dayPlan ->
|
doc.getElementsByClass("food-plan").forEach { dayPlan ->
|
||||||
@@ -126,7 +129,10 @@ class StwParser {
|
|||||||
getElementsByAttributeValue("src", preference).isNotEmpty()
|
getElementsByAttributeValue("src", preference).isNotEmpty()
|
||||||
|
|
||||||
private fun Element.getFilteredText(): String {
|
private fun Element.getFilteredText(): String {
|
||||||
var text = html().replace("&", "&")
|
var text = html()
|
||||||
|
.replace("&", "&")
|
||||||
|
.replace(">", ">")
|
||||||
|
.replace("<", "<")
|
||||||
|
|
||||||
while (text.contains("<sup>")) {
|
while (text.contains("<sup>")) {
|
||||||
text = text.substring(0 until text.indexOf("<sup>")) + text.substring(text.indexOf("</sup>")+6 until text.length)
|
text = text.substring(0 until text.indexOf("<sup>")) + text.substring(text.indexOf("</sup>")+6 until text.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user