Browse Source

Added PreferenceController

* all preferences and global variables are now inside the PreferenceController, this makes it much easier to extend the apps functionality
* CourseTTLink is now Course with courseLink and courseName as values
pull/20/head
Jannik 3 years ago
parent
commit
24f920c05f
  1. 123
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  2. 79
      app/src/main/java/org/mosad/seil0/projectlaogai/PreferencesController.kt
  3. 11
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt
  4. 4
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt
  5. 42
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  6. 27
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  7. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/DataTypes.kt
  8. 6
      app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/TimeTableParser.kt

123
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

@ -29,6 +29,7 @@ import android.view.MenuItem
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.afollestad.aesthetic.Aesthetic
import com.afollestad.materialdialogs.MaterialDialog
@ -37,25 +38,22 @@ import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cColor
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cCourseTTLinkList
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cTimeTableCurrentWeek
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cTimeTableNextWeek
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cWeekMenus
import org.mosad.seil0.projectlaogai.fragments.*
import org.mosad.seil0.projectlaogai.hsoparser.*
import org.mosad.seil0.projectlaogai.hsoparser.MensaParser
import org.mosad.seil0.projectlaogai.hsoparser.TimeTableParser
import kotlin.system.measureTimeMillis
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
private val mensaParser = MensaParser()
private val timeTableParser = TimeTableParser()
private var courseTTLinkList = ArrayList<CourseTTLink>()
private lateinit var course: CourseTTLink
private var color: Int = Color.BLACK
companion object {
var cWeekMenus = ArrayList<Meal>()
var cTimeTableCurrentWeek = arrayOf<Array<Lesson>>()
var cTimeTableNextWeek = arrayOf<Array<Lesson>>()
}
private var activeFragment: Fragment = HomeFragment() // the currently active fragment, home at the start
override fun onCreate(savedInstanceState: Bundle?) {
Aesthetic.attach(this)
@ -76,16 +74,15 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
} else {
Aesthetic.config {
colorPrimary(color)
colorPrimaryDark(color)
colorPrimary(cColor)
colorPrimaryDark(cColor)
apply()
}
}
//init home fragment TODO make a abstract fragment class
val homeFragment = HomeFragment()
//init home fragment
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, homeFragment)
fragmentTransaction.replace(R.id.fragment_container, activeFragment)
fragmentTransaction.commit()
val toggle = ActionBarDrawerToggle(
@ -135,88 +132,36 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
// Handle navigation view item clicks here.
when (item.itemId) {
R.id.nav_home -> {
val homeFragment = HomeFragment()
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, homeFragment)
fragmentTransaction.commit()
activeFragment = HomeFragment()
}
R.id.nav_mensa -> {
val mensaFragment = MensaFragment()
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, mensaFragment)
fragmentTransaction.commit()
activeFragment = MensaFragment()
}
R.id.nav_timetable -> {
val timeTableFragment = TimeTableFragment()
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, timeTableFragment)
fragmentTransaction.commit()
activeFragment = TimeTableFragment()
}
R.id.nav_moodle -> {
val moodleFragment = MoodleFragment()
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, moodleFragment)
fragmentTransaction.commit()
activeFragment = MoodleFragment()
}
R.id.nav_settings -> {
val settingsFragment = SettingsFragment()
settingsFragment.setMainActivity(this)
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, settingsFragment)
fragmentTransaction.commit()
activeFragment = SettingsFragment()
}
}
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, activeFragment)
fragmentTransaction.commit()
drawer_layout.closeDrawer(GravityCompat.START)
return true
}
/**
* update the gui with the data of the new selected course
* save selected course and courseTTLink
*/
fun updateCourse(course: CourseTTLink) {
println(course.course)
println(course.courseTTLink)
this.course = course
// save new selected course
val sharedPref = getPreferences(MODE_PRIVATE) ?: return
with (sharedPref.edit()) {
putString(getString(R.string.save_key_course), course.course)
putString(getString(R.string.save_key_courseTTLink), course.courseTTLink.replace("http", "https"))
apply()
}
cTimeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
}
/**
* save the primary color
*/
fun saveColorPrimary(color : Int) {
val sharedPref = getPreferences(MODE_PRIVATE)
with (sharedPref.edit()) {
putInt(getString(R.string.save_key_colorPrimary), color)
apply()
}
}
/**
* load the mensa menus of the current week
*/
private fun load() {
// load saved course
val sharedPref = getPreferences(MODE_PRIVATE)
course = CourseTTLink(
sharedPref.getString(getString(R.string.save_key_courseTTLink), "https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")!!,
sharedPref.getString(getString(R.string.save_key_course), "AI3")!!
)
// load saved color
color = sharedPref.getInt(getString(R.string.save_key_colorPrimary), Color.BLACK)
// load the settings
PreferencesController.load(this) // this must be finished before doing anything else
/**
* load mensa, course timetable and courselist from the swfr/hso website
@ -228,7 +173,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
* we need have time until the user opens the dialog
*/
doAsync {
courseTTLinkList = timeTableParser.getCourseTTLinks()
cCourseTTLinkList = timeTableParser.getCourseTTLinks()
}
val jobMenus = doAsync {
@ -237,7 +182,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
val jobTTCurrentWeek = doAsync {
try {
cTimeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink)
cTimeTableCurrentWeek = timeTableParser.getTimeTable(cCourse.courseLink)
} catch (e: Exception) {
uiThread {
@ -253,7 +198,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
val jobTTNextWeek = doAsync {
try {
cTimeTableNextWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("week=0","week=1"))
cTimeTableNextWeek = timeTableParser.getTimeTable(cCourse.courseLink.replace("week=0","week=1"))
} catch (e: Exception) {
e.stackTrace
}
@ -266,16 +211,4 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
println("Completed in $time ms")
}
fun getCourseTTLinkList(): ArrayList<CourseTTLink>{
return courseTTLinkList
}
fun getCourse(): CourseTTLink {
return course
}
fun getColorPrimary(): Int {
return color
}
}

79
app/src/main/java/org/mosad/seil0/projectlaogai/PreferencesController.kt

@ -0,0 +1,79 @@
/**
* ProjectLaogai
*
* Copyright 2019 <seil0@mosad.xyz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai
import android.content.Context
import android.graphics.Color
import org.jetbrains.anko.defaultSharedPreferences
import org.mosad.seil0.projectlaogai.hsoparser.Course
import org.mosad.seil0.projectlaogai.hsoparser.Lesson
import org.mosad.seil0.projectlaogai.hsoparser.Meal
/**
* The PreferencesController class
* contains all preferences and global variables that exist in this app
*/
class PreferencesController {
companion object {
var cCourseTTLinkList = ArrayList<Course>()
var cWeekMenus = ArrayList<Meal>()
var cTimeTableCurrentWeek = arrayOf<Array<Lesson>>()
var cTimeTableNextWeek = arrayOf<Array<Lesson>>()
var cColor: Int = Color.BLACK
var cCourse = Course("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0", "AI3")
// the save function
fun save(context: Context) {
println(cCourse.courseLink)
// save the course
val sharedPref = context.defaultSharedPreferences
with (sharedPref.edit()) {
putString(context.getString(R.string.save_key_course), cCourse.courseName)
putString(context.getString(R.string.save_key_courseTTLink), cCourse.courseLink)
apply()
}
// save the primary color
with (sharedPref.edit()) {
putInt(context.getString(R.string.save_key_colorPrimary), cColor)
apply()
}
}
// the load function
fun load(context: Context) {
// load saved course
val sharedPref = context.defaultSharedPreferences
cCourse = Course(
sharedPref.getString(context.getString(R.string.save_key_courseTTLink), "https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")!!,
sharedPref.getString(context.getString(R.string.save_key_course), "AI3")!!
)
// load saved color
cColor = sharedPref.getInt(context.getString(R.string.save_key_colorPrimary), Color.BLACK)
}
}
}

11
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt

@ -32,7 +32,8 @@ import com.afollestad.materialdialogs.MaterialDialog
import kotlinx.android.synthetic.main.fragment_home.*
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.MainActivity
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cTimeTableCurrentWeek
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cWeekMenus
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.*
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
@ -70,9 +71,9 @@ class HomeFragment : Fragment() {
val cal = Calendar.getInstance()
if (cal.get(Calendar.HOUR_OF_DAY) < 15) {
dayMenus = MensaParser().getMensaMenuDay(MainActivity.cWeekMenus, cal.get(Calendar.DAY_OF_WEEK))
dayMenus = MensaParser().getMensaMenuDay(cWeekMenus, cal.get(Calendar.DAY_OF_WEEK))
} else {
dayMenus = MensaParser().getMensaMenuDay(MainActivity.cWeekMenus, cal.get(Calendar.DAY_OF_WEEK) + 1)
dayMenus = MensaParser().getMensaMenuDay(cWeekMenus, cal.get(Calendar.DAY_OF_WEEK) + 1)
uiThread {
txtView_Menu1Heading.text = resources.getString(R.string.meal_1_tomorrow)
txtView_Menu2Heading.text = resources.getString(R.string.meal_2_tomorrow)
@ -121,9 +122,9 @@ class HomeFragment : Fragment() {
private fun addCurrentTimeTable() {
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
if (MainActivity.cTimeTableCurrentWeek.isNotEmpty() && dayIndex < 6) {
if (cTimeTableCurrentWeek.isNotEmpty() && dayIndex < 6) {
val timeTableDay = MainActivity.cTimeTableCurrentWeek[dayIndex]
val timeTableDay = cTimeTableCurrentWeek[dayIndex]
for (i in 0..5) {
val lessonCardView = LessonCardView(context!!, null)

4
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/MensaFragment.kt

@ -30,7 +30,7 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.MainActivity
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cWeekMenus
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
import org.mosad.seil0.projectlaogai.uicomponents.MenuCardView
@ -76,7 +76,7 @@ class MensaFragment : Fragment() {
val cardViewMensaDay = MensaDayCardView(context!!, null)
var add = false
for (meal in MainActivity.cWeekMenus) {
for (meal in cWeekMenus) {
//println("Day: " + meal.day)
if (meal.day.contains(strDay)) {

42
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -24,23 +24,29 @@ package org.mosad.seil0.projectlaogai.fragments
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.fragment.app.Fragment
import com.afollestad.aesthetic.Aesthetic
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.color.colorChooser
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.list.listItems
import kotlinx.android.synthetic.main.fragment_settings.*
import org.jetbrains.anko.Android
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.MainActivity
import org.mosad.seil0.projectlaogai.PreferencesController
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cColor
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cCourseTTLinkList
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cTimeTableCurrentWeek
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cTimeTableNextWeek
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.CourseTTLink
import java.util.ArrayList
import org.mosad.seil0.projectlaogai.hsoparser.TimeTableParser
import java.util.*
/**
* The settings controller class
@ -53,9 +59,6 @@ class SettingsFragment : Fragment() {
private lateinit var linLayoutInfo: LinearLayout
private lateinit var linLayoutMainColor: LinearLayout
private lateinit var viewPrimaryColor: View
private lateinit var courseTTLinkList: ArrayList<CourseTTLink>
private var mainActivity = MainActivity()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -76,7 +79,7 @@ class SettingsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
txtView_Course.text = mainActivity.getCourse().course
txtView_Course.text = cCourse.courseName
}
/**
@ -91,12 +94,11 @@ class SettingsFragment : Fragment() {
// open a new dialog
val courseList = ArrayList<String>()
courseTTLinkList = mainActivity.getCourseTTLinkList()
courseTTLinkList.forEach { (_, course) ->
cCourseTTLinkList.forEach { (_, course) ->
courseList.add(course)
}
MaterialDialog(context!!).listItems(items = courseList){ _, index, text ->
MaterialDialog(context!!).listItems(items = courseList) { _, index, text ->
txtView_Course.text = text // update txtView
val dialog = MaterialDialog(context!!).cancelable(false)
@ -105,7 +107,12 @@ class SettingsFragment : Fragment() {
dialog.show()
doAsync {
mainActivity.updateCourse(courseTTLinkList[index])
cCourse = cCourseTTLinkList[index] // set the course
PreferencesController.save(context!!)
// update current & next weeks timetable
cTimeTableCurrentWeek = TimeTableParser().getTimeTable(cCourse.courseLink)
cTimeTableNextWeek = TimeTableParser().getTimeTable(cCourse.courseLink.replace("week=0","week=1"))
uiThread {
dialog.dismiss()
@ -113,7 +120,7 @@ class SettingsFragment : Fragment() {
}
}
.show()
.show()
}
linLayoutInfo.setOnClickListener {
@ -130,7 +137,7 @@ class SettingsFragment : Fragment() {
MaterialDialog(context!!)
.title(R.string.primary_color)
.colorChooser(colors, allowCustomArgb = true,initialSelection = mainActivity.getColorPrimary()) { _, color ->
.colorChooser(colors, allowCustomArgb = true, initialSelection = cColor) { _, color ->
viewPrimaryColor.setBackgroundColor(color)
Aesthetic.config {
colorPrimary(color)
@ -138,15 +145,12 @@ class SettingsFragment : Fragment() {
apply()
}
mainActivity.saveColorPrimary(color)
cColor = color
PreferencesController.save(context!!)
}
.positiveButton(R.string.select)
.show()
}
}
fun setMainActivity(mainActivity: MainActivity) {
this.mainActivity = mainActivity
}
}

27
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -24,14 +24,15 @@ package org.mosad.seil0.projectlaogai.fragments
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.fragment.app.Fragment
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.MainActivity
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cTimeTableCurrentWeek
import org.mosad.seil0.projectlaogai.PreferencesController.Companion.cTimeTableNextWeek
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
@ -54,7 +55,7 @@ class TimeTableFragment : Fragment() {
linLayoutTTFragment = view.findViewById(R.id.linLayout_TTFragment)
if (MainActivity.cTimeTableCurrentWeek.isNotEmpty()) {
if (cTimeTableCurrentWeek.isNotEmpty()) {
addCurrentWeek()
} else {
// TODO show card with error msg
@ -76,12 +77,12 @@ class TimeTableFragment : Fragment() {
uiThread {
// add current weeks days
for(day in dayIndex..5) {
for (day in dayIndex..5) {
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time))
// for each lessen of the day
for((i, lesson) in MainActivity.cTimeTableCurrentWeek[day].withIndex()) {
for ((i, lesson) in cTimeTableCurrentWeek[day].withIndex()) {
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.setBackgroundColor(Color.TRANSPARENT)
@ -91,11 +92,11 @@ class TimeTableFragment : Fragment() {
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
// only add the lesson if it contains data
if(lessonCardView.getTxtViewLesson().text.length > 2)
if (lessonCardView.getTxtViewLesson().text.length > 2)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
}
calendar.add(Calendar.DATE,1)
calendar.add(Calendar.DATE, 1)
// if the day contains no lessons add a text "No lesson today"
if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) {
@ -110,16 +111,16 @@ class TimeTableFragment : Fragment() {
// TODO if there is no lesson at one day , show a no lesson card
// add next weeks days, max number = dayIndex, if timetable was loaded
if (MainActivity.cTimeTableNextWeek.isNotEmpty()) {
calendar.add(Calendar.DATE,1) // before this we are at a sunday (no lecture on sundays!)
if (cTimeTableNextWeek.isNotEmpty()) {
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
for(day in 0..(dayIndex - 1)) {
for (day in 0..(dayIndex - 1)) {
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time))
// for each lessen of the day
for((i, lesson) in MainActivity.cTimeTableNextWeek[day].withIndex()) {
for ((i, lesson) in cTimeTableNextWeek[day].withIndex()) {
val lessonCardView = LessonCardView(context!!, null)
lessonCardView.setBackgroundColor(Color.TRANSPARENT)
@ -128,11 +129,11 @@ class TimeTableFragment : Fragment() {
lessonCardView.getTxtViewLesson().append(lesson.lessonRoom)
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
if(lessonCardView.getTxtViewLesson().text.length > 2)
if (lessonCardView.getTxtViewLesson().text.length > 2)
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
}
calendar.add(Calendar.DATE,1)
calendar.add(Calendar.DATE, 1)
linLayoutTTFragment.addView(cardViewTimeTableDay)
}
}

2
app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/DataTypes.kt

@ -58,6 +58,6 @@ class NotRetardedCalendar {
data class Lesson(val lessonSubject: String, val lessonTeacher: String, val lessonRoom:String, val lessonRemark: String)
data class CourseTTLink(val courseTTLink: String, val course: String)
data class Course(val courseLink: String, val courseName: String)
data class Meal(val day: String, val heading: String, val parts: ArrayList<String>, val additives: String)

6
app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/TimeTableParser.kt

@ -26,7 +26,7 @@ import org.jsoup.Jsoup
class TimeTableParser {
private val days = arrayOf("Monday", "Tuesday" ,"Wednesday", "Thursday", "Friday", "Saturday")
private var courseTTLinkList = ArrayList<CourseTTLink>()
private var courseTTLinkList = ArrayList<Course>()
/**
* get the timetable from the given url
@ -59,11 +59,11 @@ class TimeTableParser {
/**
* parse all courses from the courses site at https://www.hs-offenburg.de/studium/vorlesungsplaene/
*/
fun getCourseTTLinks(): ArrayList<CourseTTLink> {
fun getCourseTTLinks(): ArrayList<Course> {
val courseHTML = Jsoup.connect("https://www.hs-offenburg.de/studium/vorlesungsplaene/").get()
courseHTML.select("ul.index-group").select("li.Class").select("a[href]").forEachIndexed { _, element ->
courseTTLinkList.add(CourseTTLink(element.attr("href"),element.text()))
courseTTLinkList.add(Course(element.attr("href").replace("http", "https"),element.text()))
}
return courseTTLinkList
}

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close