added the mensa parser
This commit is contained in:
parent
5fd9db182a
commit
47d48fb4d9
|
@ -30,6 +30,7 @@ dependencies {
|
||||||
implementation 'com.google.android.material:material:1.0.0'
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
|
||||||
implementation 'org.jsoup:jsoup:1.11.3'
|
implementation 'org.jsoup:jsoup:1.11.3'
|
||||||
|
implementation "org.jetbrains.anko:anko-commons:0.10.4"
|
||||||
|
|
||||||
implementation 'com.afollestad.material-dialogs:core:2.0.0-beta4'
|
implementation 'com.afollestad.material-dialogs:core:2.0.0-beta4'
|
||||||
implementation 'com.afollestad.material-dialogs:color:2.0.0-beta4'
|
implementation 'com.afollestad.material-dialogs:color:2.0.0-beta4'
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.mosad.seil0.projectlaogai">
|
package="org.mosad.seil0.projectlaogai">
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package ord.mosad.seil0.projectlaogai.uicomponents
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
|
||||||
import org.mosad.seil0.projectlaogai.R
|
|
||||||
|
|
||||||
class MensaDayCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
|
|
||||||
|
|
||||||
private var linLayoutMensaDay: LinearLayout
|
|
||||||
private var txtViewDayHeading: TextView
|
|
||||||
|
|
||||||
init {
|
|
||||||
inflate(context, R.layout.mensaday_cardview,this)
|
|
||||||
|
|
||||||
linLayoutMensaDay = findViewById(R.id.linLayout_MensaDay)
|
|
||||||
txtViewDayHeading = findViewById(R.id.txtView_DayHeading)
|
|
||||||
|
|
||||||
// workaround to prevent a white border
|
|
||||||
//this.setBackgroundColor(Color.TRANSPARENT)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getLinLayoutMensaDay(): LinearLayout {
|
|
||||||
return linLayoutMensaDay
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -32,7 +32,13 @@ import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import ord.mosad.seil0.projectlaogai.uicomponents.LessonCardView
|
import org.jetbrains.anko.doAsync
|
||||||
|
|
||||||
|
import org.jetbrains.anko.uiThread
|
||||||
|
import org.mosad.seil0.projectlaogai.hsoparser.Meal
|
||||||
|
import org.mosad.seil0.projectlaogai.hsoparser.MensaParser
|
||||||
|
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "home" controller class
|
* The "home" controller class
|
||||||
|
@ -57,7 +63,8 @@ class HomeFragment : Fragment() {
|
||||||
scrollViewTimeTable = view.findViewById(R.id.scrollView_TimeTable)
|
scrollViewTimeTable = view.findViewById(R.id.scrollView_TimeTable)
|
||||||
linLayoutTimeTable = view.findViewById(R.id.linLayout_TimeTable)
|
linLayoutTimeTable = view.findViewById(R.id.linLayout_TimeTable)
|
||||||
|
|
||||||
setText()
|
//setText()
|
||||||
|
addCurentMensaMenu()
|
||||||
|
|
||||||
addLessons()
|
addLessons()
|
||||||
|
|
||||||
|
@ -65,10 +72,24 @@ class HomeFragment : Fragment() {
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
private fun addCurentMensaMenu() {
|
||||||
private fun setText() {
|
|
||||||
txtViewMenu1.text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
|
doAsync {
|
||||||
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
|
val mensaParser = MensaParser()
|
||||||
|
val dayMenus: ArrayList<Meal> = mensaParser.getMensaMenuDay(mensaParser.getMensaMenu(), Calendar.getInstance().get(Calendar.DAY_OF_WEEK))
|
||||||
|
|
||||||
|
uiThread {
|
||||||
|
for(part in dayMenus[0].parts) {
|
||||||
|
txtViewMenu1.append(part)
|
||||||
|
}
|
||||||
|
|
||||||
|
for(part in dayMenus[1].parts) {
|
||||||
|
txtViewMenu2.append(part)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
|
|
|
@ -29,8 +29,14 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import ord.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
import kotlinx.android.synthetic.main.mensaday_cardview.view.*
|
||||||
import ord.mosad.seil0.projectlaogai.uicomponents.MenuCardView
|
import org.jetbrains.anko.doAsync
|
||||||
|
import org.jetbrains.anko.uiThread
|
||||||
|
import org.mosad.seil0.projectlaogai.hsoparser.Meal
|
||||||
|
import org.mosad.seil0.projectlaogai.hsoparser.MensaParser
|
||||||
|
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
||||||
|
import org.mosad.seil0.projectlaogai.uicomponents.MenuCardView
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mensa controller class
|
* The mensa controller class
|
||||||
|
@ -46,40 +52,86 @@ class MensaFragment : Fragment() {
|
||||||
|
|
||||||
linLayoutMensaFragment = view.findViewById(R.id.linLayout_MensaFragment)
|
linLayoutMensaFragment = view.findViewById(R.id.linLayout_MensaFragment)
|
||||||
|
|
||||||
addDay()
|
addCurrentWeek()
|
||||||
|
//addDay(Calendar.getInstance().get(Calendar.DAY_OF_WEEK))
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
fun addCurrentWeek() {
|
||||||
fun addDay() {
|
|
||||||
|
|
||||||
|
doAsync {
|
||||||
|
val mensaParser = MensaParser()
|
||||||
|
val weekMenus: ArrayList<Meal> = mensaParser.getMensaMenu()
|
||||||
|
|
||||||
|
uiThread {
|
||||||
|
|
||||||
|
for(day in Calendar.getInstance().get(Calendar.DAY_OF_WEEK)..7) {
|
||||||
|
|
||||||
|
var strDay: String = when(day) {
|
||||||
|
Calendar.MONDAY -> "Mon"
|
||||||
|
Calendar.TUESDAY -> "Die"
|
||||||
|
Calendar.WEDNESDAY -> "Mit"
|
||||||
|
Calendar.THURSDAY -> "Don"
|
||||||
|
Calendar.FRIDAY -> "Fre"
|
||||||
|
Calendar.SATURDAY -> "Sam"
|
||||||
|
else -> "TODAY" //TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
val cardViewMensaDay = MensaDayCardView(context!!, null)
|
||||||
|
var add = false
|
||||||
|
|
||||||
|
for (meal in weekMenus) {
|
||||||
|
//println("Day: " + meal.day)
|
||||||
|
if (meal.day.contains(strDay)) {
|
||||||
|
|
||||||
|
val menuViewMenu = MenuCardView(context!!, null)
|
||||||
|
menuViewMenu.setMenuHeading(meal.heading)
|
||||||
|
|
||||||
|
for(part in meal.parts) {
|
||||||
|
menuViewMenu.getTxtViewMenu().append(part)
|
||||||
|
}
|
||||||
|
|
||||||
|
cardViewMensaDay.setDayHeading(meal.day) //TODO move this out of the first for loop, performance!!
|
||||||
|
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu)
|
||||||
|
add = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(add)
|
||||||
|
linLayoutMensaFragment.addView(cardViewMensaDay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addDay(day: Int) {
|
||||||
val cardViewMensaDay = MensaDayCardView(context!!, null)
|
val cardViewMensaDay = MensaDayCardView(context!!, null)
|
||||||
val menuViewMenu1 = MenuCardView(context!!, null)
|
|
||||||
val menuViewMenu2 = MenuCardView(context!!, null)
|
|
||||||
|
|
||||||
menuViewMenu1.getTxtViewMenuHeading().text = "Essen 1"
|
doAsync {
|
||||||
menuViewMenu1.getTxtViewMenu().text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
|
val mensaParser = MensaParser()
|
||||||
menuViewMenu2.getTxtViewMenuHeading().text = "Essen 2"
|
val dayMenus: ArrayList<Meal> = mensaParser.getMensaMenuDay(mensaParser.getMensaMenu(), day)
|
||||||
menuViewMenu2.getTxtViewMenu().text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
|
|
||||||
|
|
||||||
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu1)
|
uiThread {
|
||||||
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu2)
|
|
||||||
linLayoutMensaFragment.addView(cardViewMensaDay)
|
|
||||||
|
|
||||||
|
for (meal in dayMenus) {
|
||||||
|
val menuViewMenu = MenuCardView(context!!, null)
|
||||||
|
menuViewMenu.setMenuHeading(meal.heading)
|
||||||
|
|
||||||
val cardViewMensaDay2 = MensaDayCardView(context!!, null)
|
for(part in meal.parts) {
|
||||||
val menuViewMenu12 = MenuCardView(context!!, null)
|
menuViewMenu.getTxtViewMenu().append(part)
|
||||||
val menuViewMenu22 = MenuCardView(context!!, null)
|
}
|
||||||
|
|
||||||
menuViewMenu12.getTxtViewMenuHeading().text = "Essen 12"
|
cardViewMensaDay.setDayHeading(meal.day) //TODO move this out of the first for loop, performance!!
|
||||||
menuViewMenu12.getTxtViewMenu().text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
|
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu)
|
||||||
menuViewMenu22.getTxtViewMenuHeading().text = "Essen 22"
|
}
|
||||||
menuViewMenu22.getTxtViewMenu().text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
|
|
||||||
|
|
||||||
cardViewMensaDay2.getLinLayoutMensaDay().addView(menuViewMenu12)
|
linLayoutMensaFragment.addView(cardViewMensaDay)
|
||||||
cardViewMensaDay2.getLinLayoutMensaDay().addView(menuViewMenu22)
|
}
|
||||||
linLayoutMensaFragment.addView(cardViewMensaDay2)
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.mosad.seil0.projectlaogai.hsoparser
|
||||||
|
|
||||||
|
class DataTypes {
|
||||||
|
init {
|
||||||
|
// do something
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 Meal(val day: String, val heading: String, val parts: ArrayList<String>, val additives: String)
|
|
@ -0,0 +1,82 @@
|
||||||
|
/**
|
||||||
|
* ProjectLaogai
|
||||||
|
*
|
||||||
|
* Copyright 2018 <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.hsoparser
|
||||||
|
|
||||||
|
import org.jsoup.Jsoup
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class MensaParser {
|
||||||
|
private var mealList = ArrayList<Meal>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
// do something
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the mensa menu for the whole week
|
||||||
|
*/
|
||||||
|
fun getMensaMenu(): ArrayList<Meal> {
|
||||||
|
val menuHTML = Jsoup.connect("https://www.swfr.de/de/essen-trinken/speiseplaene/mensa-offenburg/").get()
|
||||||
|
|
||||||
|
menuHTML.select("#speiseplan-tabs").select("div.tab-content").select("div.menu-tagesplan").forEachIndexed { index, element ->
|
||||||
|
var day = element.select("h3").text()
|
||||||
|
for (i in 0 .. (element.select("div.row h4").size - 1)) {
|
||||||
|
try {
|
||||||
|
var heading = element.select("div.row h4")[i].text()
|
||||||
|
var parts = ArrayList<String>(element.select("div.row").select("div.menu-info")[i].html().substringBefore("<span").replace("<br>", "|").split("|"))
|
||||||
|
var additives = element.select("div.row").select("div.menu-info")[i].select("span.show-with-allergenes").text()
|
||||||
|
|
||||||
|
mealList.add(Meal(day, heading, parts, additives))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// catch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mealList
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the mensa menu of a given day (Mon - Sat)
|
||||||
|
*/
|
||||||
|
fun getMensaMenuDay(mealList: ArrayList<Meal>, day: Int): ArrayList<Meal> {
|
||||||
|
var dayMenus = ArrayList<Meal>()
|
||||||
|
var strDay: String = when(day) {
|
||||||
|
Calendar.MONDAY -> "Mon"
|
||||||
|
Calendar.TUESDAY -> "Die"
|
||||||
|
Calendar.WEDNESDAY -> "Mit"
|
||||||
|
Calendar.THURSDAY -> "Don"
|
||||||
|
Calendar.FRIDAY -> "Fre"
|
||||||
|
Calendar.SATURDAY -> "Sam"
|
||||||
|
else -> "TODAY" //TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
for (meal in mealList) {
|
||||||
|
if (meal.day.contains(strDay)) {
|
||||||
|
println(meal.day)
|
||||||
|
dayMenus.add(meal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dayMenus
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**
|
||||||
|
* ProjectLaogai
|
||||||
|
*
|
||||||
|
* Copyright 2018 <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.hsoparser
|
||||||
|
|
||||||
|
import org.jsoup.Jsoup
|
||||||
|
|
||||||
|
class TimeTableParser {
|
||||||
|
val days = arrayOf("Monday", "Tuesday" ,"Wednesday", "Thursday", "Friday", "Saturday")
|
||||||
|
var courseTTLinkList = ArrayList<CourseTTLink>()
|
||||||
|
var timeTableWeek = arrayOf<Array<Lesson>>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
// create the timetable array
|
||||||
|
for (i in 0..5) {
|
||||||
|
var timeTableDay = arrayOf<Lesson>()
|
||||||
|
for (j in 0..6) {
|
||||||
|
timeTableDay += Lesson("", "","","")
|
||||||
|
}
|
||||||
|
timeTableWeek += timeTableDay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the timetable from the given url
|
||||||
|
* the timetable is organised per row not per column;
|
||||||
|
* Mon 1, Tue 1, Wed 1, Thur 1, Fri 1, Sat 1, Mon 2 and so on
|
||||||
|
*/
|
||||||
|
fun getTimeTable(courseTTURL: String) {
|
||||||
|
val scheduleHTML = Jsoup.connect(courseTTURL).get()
|
||||||
|
|
||||||
|
val week = scheduleHTML.select("h1.timetable-caption").text()
|
||||||
|
println("$week successful!\n")
|
||||||
|
|
||||||
|
scheduleHTML.select("table.timetable").select("td.lastcol").forEachIndexed { index, element ->
|
||||||
|
timeTableWeek[index % 6][index / 6] = Lesson(element.select("div.lesson-subject").text(), element.select("div.lesson-teacher").text(), element.select("div.lesson-room").text(), element.select("div.lesson-remark").text())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parse all courses from the courses site at https://www.hs-offenburg.de/studium/vorlesungsplaene/
|
||||||
|
*/
|
||||||
|
fun getCourseTTLinks() {
|
||||||
|
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()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun printTimeTableWeek (timeTableWeek: Array<Array<Lesson>>) {
|
||||||
|
|
||||||
|
for (j in 0..5) print(days[j].padEnd(25 ,' ') + " | ")
|
||||||
|
println()
|
||||||
|
for (j in 0..5) print("-".padEnd(26 + (j.toFloat().div(j).toInt()), '-') + "+")
|
||||||
|
println()
|
||||||
|
|
||||||
|
for (i in 0..6) {
|
||||||
|
for (j in 0..5) print(timeTableWeek[j][i].lessonSubject.padEnd(25 ,' ').substring(0,25) + " | ")
|
||||||
|
println()
|
||||||
|
for (j in 0..5) print(timeTableWeek[j][i].lessonTeacher.padEnd(25 ,' ').substring(0,25) + " | ")
|
||||||
|
println()
|
||||||
|
for (j in 0..5) print(timeTableWeek[j][i].lessonRoom.padEnd(25 ,' ').substring(0,25) + " | ")
|
||||||
|
println()
|
||||||
|
for (j in 0..5) print("-".padEnd(26 + (j.toFloat().div(j).toInt()), '-') + "+")
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun printTimeTableDay(timeTableDay: Array<Lesson>, day: Int) {
|
||||||
|
println(days[day])
|
||||||
|
for (i in 0..6) {
|
||||||
|
println("-".padEnd(22, '-'))
|
||||||
|
println(timeTableDay[i].lessonSubject)
|
||||||
|
println(timeTableDay[i].lessonTeacher)
|
||||||
|
println(timeTableDay[i].lessonRoom)
|
||||||
|
}
|
||||||
|
println("-".padEnd(22, '-'))
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ord.mosad.seil0.projectlaogai.uicomponents
|
package org.mosad.seil0.projectlaogai.uicomponents
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
|
@ -0,0 +1,54 @@
|
||||||
|
/**
|
||||||
|
* ProjectLaogai
|
||||||
|
*
|
||||||
|
* Copyright 2018 <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.uicomponents
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import org.mosad.seil0.projectlaogai.R
|
||||||
|
|
||||||
|
class MensaDayCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
|
||||||
|
|
||||||
|
private var linLayoutMensaDay: LinearLayout
|
||||||
|
private var txtViewDayHeading: TextView
|
||||||
|
|
||||||
|
init {
|
||||||
|
inflate(context, R.layout.mensaday_cardview,this)
|
||||||
|
|
||||||
|
linLayoutMensaDay = findViewById(R.id.linLayout_MensaDay)
|
||||||
|
txtViewDayHeading = findViewById(R.id.txtView_DayHeading)
|
||||||
|
|
||||||
|
// workaround to prevent a white border
|
||||||
|
//this.setBackgroundColor(Color.TRANSPARENT)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLinLayoutMensaDay(): LinearLayout {
|
||||||
|
return linLayoutMensaDay
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDayHeading(heading: String) {
|
||||||
|
txtViewDayHeading.text = heading
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package ord.mosad.seil0.projectlaogai.uicomponents
|
package org.mosad.seil0.projectlaogai.uicomponents
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
@ -25,6 +25,10 @@ class MenuCardView @JvmOverloads constructor(context: Context, attrs: AttributeS
|
||||||
return txtViewMenuHeading
|
return txtViewMenuHeading
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setMenuHeading(heading: String) {
|
||||||
|
txtViewMenuHeading.text = heading
|
||||||
|
}
|
||||||
|
|
||||||
fun getTxtViewMenu(): TextView {
|
fun getTxtViewMenu(): TextView {
|
||||||
return txtViewMenu
|
return txtViewMenu
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/cardView"
|
android:id="@+id/cardView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="125dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="5dp"
|
android:layout_marginStart="5dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
|
|
Loading…
Reference in New Issue