timetable and mensa gui redesign
* the timetable and mensa screen are now the same design as the settings, much cleaner and ready for themes
This commit is contained in:
@ -38,8 +38,8 @@ import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timeta
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.Meal
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonLinearLayout
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@ -127,50 +127,49 @@ class HomeFragment : Fragment() {
|
||||
*/
|
||||
private fun addCurrentTimeTable() {
|
||||
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
||||
var helpLesson = LessonLinearLayout(context!!)
|
||||
val dayCardView = DayCardView(context!!)
|
||||
dayCardView.setDayHeading("Heute")
|
||||
|
||||
if (timetables[0].days.isNotEmpty() && dayIndex < 6) {
|
||||
|
||||
val timeTableDay = timetables[0].days[dayIndex]
|
||||
|
||||
// for all timeslots of the day
|
||||
for ((i, timeslot) in timeTableDay.timeslots.withIndex()) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||
for ((tsIndex, timeslot) in timetables[0].days[dayIndex].timeslots.withIndex()) {
|
||||
|
||||
for (lesson in timeslot) {
|
||||
val lessonTxtView = LessonTextView(context!!)
|
||||
lessonTxtView.setLesson(lesson)
|
||||
for(lesson in timeslot) {
|
||||
if(lesson.lessonSubject.isNotEmpty()) {
|
||||
|
||||
// make sure no empty lesson is added
|
||||
if (lessonTxtView.text.length > 3)
|
||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||
val lessonLayout = LessonLinearLayout(context!!)
|
||||
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
||||
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
||||
|
||||
if (lesson != timeslot.last()) {
|
||||
lessonLayout.disableDivider()
|
||||
}
|
||||
|
||||
helpLesson = lessonLayout
|
||||
}
|
||||
}
|
||||
|
||||
if (lessonCardView.getLinLayoutLesson().childCount > 1)
|
||||
linLayoutTimeTable.addView(lessonCardView)
|
||||
}
|
||||
|
||||
// add a card if there is no lesson today
|
||||
if (linLayoutTimeTable.childCount == 0) {
|
||||
helpLesson.disableDivider()
|
||||
// if there are no lessons don't show the dayCardView
|
||||
if (dayCardView.getLinLayoutDay().childCount > 1) {
|
||||
linLayoutTimeTable.addView(dayCardView)
|
||||
} else {
|
||||
// TODO we could display the next day with a lecture
|
||||
val lessonTxtView = LessonTextView(context!!)
|
||||
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
|
||||
val noLesson = DayCardView(context!!)
|
||||
noLesson.setDayHeading(resources.getString(R.string.no_lesson_today))
|
||||
|
||||
val noLessonCardView = LessonCardView(context!!, null)
|
||||
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||
|
||||
linLayoutTimeTable.addView(noLessonCardView)
|
||||
linLayoutTimeTable.addView(noLesson)
|
||||
}
|
||||
} else {
|
||||
if (dayIndex == 6) {
|
||||
// if that's the case it's sunday
|
||||
val lessonTxtView = LessonTextView(context!!)
|
||||
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
|
||||
val noLesson = DayCardView(context!!)
|
||||
noLesson.setDayHeading(resources.getString(R.string.no_lesson_today))
|
||||
|
||||
val noLessonCardView = LessonCardView(context!!, null)
|
||||
noLessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||
|
||||
linLayoutTimeTable.addView(noLessonCardView)
|
||||
linLayoutTimeTable.addView(noLesson)
|
||||
} else {
|
||||
MaterialDialog(context!!)
|
||||
.title(R.string.error)
|
||||
|
@ -28,16 +28,17 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import kotlinx.android.synthetic.main.fragment_mensa.*
|
||||
import org.jetbrains.anko.doAsync
|
||||
import org.jetbrains.anko.uiThread
|
||||
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cShowBuffet
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaCurrentWeek
|
||||
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaNextWeek
|
||||
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cShowBuffet
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.MensaWeek
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.MenuCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
||||
|
||||
/**
|
||||
* The mensa controller class
|
||||
@ -51,7 +52,7 @@ class MensaFragment : Fragment() {
|
||||
|
||||
val view: View = inflater.inflate(R.layout.fragment_mensa, container, false)
|
||||
|
||||
linLayoutMensaFragment = view.findViewById(R.id.linLayout_MensaFragment)
|
||||
linLayoutMensaFragment = view.findViewById(R.id.linLayout_Mensa)
|
||||
|
||||
// add the current week (week starts on sunday)
|
||||
val dayCurrent = if(NotRetardedCalendar().getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar().getDayOfWeekIndex()
|
||||
@ -71,37 +72,34 @@ class MensaFragment : Fragment() {
|
||||
doAsync {
|
||||
|
||||
uiThread {
|
||||
|
||||
// only add the days dayStart to Fri since the mensa is closed on Sat/Sun
|
||||
for (dayIndex in dayStart..4) {
|
||||
|
||||
val cardViewMensaDay = MensaDayCardView(context!!, null)
|
||||
var helpMeal = MealLinearLayout(context)
|
||||
val dayCardView = DayCardView(context!!)
|
||||
dayCardView.setDayHeading(menusWeek.days[dayIndex].meals[0].day)
|
||||
|
||||
for (meal in menusWeek.days[dayIndex].meals) {
|
||||
val menuViewMenu = MenuCardView(context!!, null)
|
||||
menuViewMenu.setMenuHeading(meal.heading)
|
||||
val mealLayout = MealLinearLayout(context)
|
||||
mealLayout.setMeal(meal)
|
||||
|
||||
meal.parts.forEachIndexed { partIndex, part ->
|
||||
menuViewMenu.getTxtViewMenu().append(part)
|
||||
if(partIndex < (meal.parts.size - 1))
|
||||
menuViewMenu.getTxtViewMenu().append("\n")
|
||||
if(meal.heading != "Buffet" || cShowBuffet) {
|
||||
dayCardView.getLinLayoutDay().addView(mealLayout)
|
||||
helpMeal = mealLayout
|
||||
}
|
||||
|
||||
cardViewMensaDay.setDayHeading(meal.day)
|
||||
|
||||
if(meal.heading != "Buffet" || cShowBuffet)
|
||||
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu)
|
||||
}
|
||||
|
||||
if(cardViewMensaDay.getLinLayoutMensaDay().childCount > 1)
|
||||
linLayoutMensaFragment.addView(cardViewMensaDay)
|
||||
helpMeal.disableDivider()
|
||||
|
||||
if(dayCardView.getLinLayoutDay().childCount > 1)
|
||||
linLayoutMensaFragment.addView(dayCardView)
|
||||
}
|
||||
|
||||
// add a card if there are no more meals in this week
|
||||
if(linLayoutMensaFragment.childCount == 0) {
|
||||
val cardViewNoMoreFood = MensaDayCardView(context!!, null)
|
||||
cardViewNoMoreFood.setDayHeading(resources.getString(R.string.no_more_food))
|
||||
linLayoutMensaFragment.addView(cardViewNoMoreFood)
|
||||
val noFood = DayCardView(context!!)
|
||||
noFood.setDayHeading(resources.getString(R.string.no_more_food))
|
||||
linLayout_Mensa.addView(noFood)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ class MoodleFragment : Fragment() {
|
||||
webView = view.findViewById(R.id.webView)
|
||||
webView.loadUrl("https://elearning.hs-offenburg.de/moodle/")
|
||||
|
||||
webSettings = webView.getSettings()
|
||||
webSettings = webView.settings
|
||||
//webSettings.setJavaScriptEnabled(true) // Enable Javascript
|
||||
|
||||
webView.setWebViewClient(WebViewClient()) // Force links and redirects to open in the WebView instead of in a browser
|
||||
webView.webViewClient = WebViewClient() // Force links and redirects to open in the WebView instead of in a browser
|
||||
|
||||
return view
|
||||
}
|
||||
|
@ -26,17 +26,15 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import kotlinx.android.synthetic.main.fragment_timetable.*
|
||||
import org.jetbrains.anko.doAsync
|
||||
import org.jetbrains.anko.uiThread
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timetables
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonTextView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
|
||||
import org.mosad.seil0.projectlaogai.uicomponents.*
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@ -46,16 +44,12 @@ import java.util.*
|
||||
*/
|
||||
class TimeTableFragment : Fragment() {
|
||||
|
||||
private lateinit var linLayoutTTFragment: LinearLayout
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
||||
val view: View = inflater.inflate(R.layout.fragment_timetable, container, false)
|
||||
|
||||
linLayoutTTFragment = view.findViewById(R.id.linLayout_TTFragment)
|
||||
|
||||
if (timetables[0].days.isNotEmpty()) {
|
||||
addCurrentWeek()
|
||||
if (timetables[0].days.isNotEmpty() && timetables[1].days.isNotEmpty()) {
|
||||
addWeeks()
|
||||
} else {
|
||||
// TODO show card with error msg
|
||||
}
|
||||
@ -64,9 +58,9 @@ class TimeTableFragment : Fragment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* add the remaining days of the current week to the timetable screen
|
||||
* add the all days with at least one lesson to the timetable screen
|
||||
*/
|
||||
private fun addCurrentWeek() {
|
||||
private fun addWeeks() {
|
||||
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
||||
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24
|
||||
val calendar = Calendar.getInstance()
|
||||
@ -75,91 +69,76 @@ class TimeTableFragment : Fragment() {
|
||||
|
||||
uiThread {
|
||||
|
||||
// add current weeks days
|
||||
// add the current week
|
||||
for (day in dayIndex..5) {
|
||||
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
|
||||
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time))
|
||||
var helpLesson = LessonLinearLayout(context)
|
||||
val dayCardView = DayCardView(context!!)
|
||||
dayCardView.setDayHeading(formatter.format(calendar.time))
|
||||
|
||||
// for each timeslot of the day
|
||||
for ((i, timeslot) in timetables[0].days[day].timeslots.withIndex()) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||
for ((tsIndex, timeslot) in timetables[0].days[day].timeslots.withIndex()) {
|
||||
|
||||
//println(timeslot)
|
||||
for(lesson in timeslot) {
|
||||
|
||||
for (lesson in timeslot) {
|
||||
val lessonTxtView = LessonTextView(context!!)
|
||||
lessonTxtView.setLesson(lesson)
|
||||
if(lesson.lessonSubject.isNotEmpty()) {
|
||||
|
||||
// make sure no empty lesson is added
|
||||
if (lessonTxtView.text.length > 3)
|
||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||
val lessonLayout = LessonLinearLayout(context)
|
||||
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
||||
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
||||
|
||||
if (lesson != timeslot.last()) {
|
||||
lessonLayout.disableDivider()
|
||||
}
|
||||
|
||||
helpLesson = lessonLayout
|
||||
}
|
||||
}
|
||||
|
||||
// only add the lesson if it contains data
|
||||
if (lessonCardView.getLinLayoutLesson().childCount > 1)
|
||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||
}
|
||||
|
||||
helpLesson.disableDivider()
|
||||
calendar.add(Calendar.DATE, 1)
|
||||
|
||||
// if the day contains no lessons add a text "No lesson today"
|
||||
if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) {
|
||||
val lessonTxtView = LessonTextView(context!!)
|
||||
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
|
||||
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||
|
||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||
// if there are no lessons don't show the dayCardView
|
||||
if (dayCardView.getLinLayoutDay().childCount > 1) {
|
||||
linLayout_Timetable.addView(dayCardView)
|
||||
}
|
||||
|
||||
linLayoutTTFragment.addView(cardViewTimeTableDay)
|
||||
}
|
||||
|
||||
// add next weeks days, max number = dayIndex, if timetable was loaded
|
||||
if (timetables[1].days.isNotEmpty()) {
|
||||
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
|
||||
|
||||
for (day in 0..(dayIndex - 1)) {
|
||||
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
|
||||
|
||||
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
|
||||
cardViewTimeTableDay.setDayHeading(formatter.format(calendar.time))
|
||||
// add the next week
|
||||
for (day in 0..(dayIndex - 1)) {
|
||||
var helpLesson = LessonLinearLayout(context!!)
|
||||
val dayCardView = DayCardView(context!!)
|
||||
dayCardView.setDayHeading(formatter.format(calendar.time))
|
||||
|
||||
// for each timeslot of the day
|
||||
for ((i, timeslot) in timetables[1].days[day].timeslots.withIndex()) {
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i]
|
||||
// for each timeslot of the day
|
||||
for ((tsIndex, timeslot) in timetables[1].days[day].timeslots.withIndex()) {
|
||||
|
||||
for(lesson in timeslot) {
|
||||
|
||||
for (lesson in timeslot) {
|
||||
val lessonTxtView = LessonTextView(context!!)
|
||||
lessonTxtView.setLesson(lesson)
|
||||
if(lesson.lessonSubject.isNotEmpty()) {
|
||||
|
||||
// make sure no empty lesson is added
|
||||
if (lessonTxtView.text.length > 3)
|
||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||
val lessonLayout = LessonLinearLayout(context!!)
|
||||
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
||||
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
||||
|
||||
if (lesson != timeslot.last()) {
|
||||
lessonLayout.disableDivider()
|
||||
}
|
||||
|
||||
helpLesson = lessonLayout
|
||||
}
|
||||
|
||||
// only add the lesson if it contains data
|
||||
if (lessonCardView.getLinLayoutLesson().childCount > 1)
|
||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||
}
|
||||
}
|
||||
|
||||
calendar.add(Calendar.DATE, 1)
|
||||
helpLesson.disableDivider()
|
||||
calendar.add(Calendar.DATE, 1)
|
||||
|
||||
// if the day contains no lessons add a text "No lesson today"
|
||||
if (cardViewTimeTableDay.getLinLayoutMensaDay().childCount <= 1) {
|
||||
val lessonTxtView = LessonTextView(context!!)
|
||||
lessonTxtView.setText(resources.getString(R.string.no_lesson_today))
|
||||
|
||||
val lessonCardView = LessonCardView(context!!, null)
|
||||
lessonCardView.getLinLayoutLesson().addView(lessonTxtView)
|
||||
|
||||
cardViewTimeTableDay.getLinLayoutMensaDay().addView(lessonCardView)
|
||||
}
|
||||
|
||||
linLayoutTTFragment.addView(cardViewTimeTableDay)
|
||||
// if there are no lessons don't show the dayCardView
|
||||
if (dayCardView.getLinLayoutDay().childCount > 1) {
|
||||
linLayout_Timetable.addView(dayCardView)
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,4 +147,5 @@ class TimeTableFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,32 +24,26 @@ package org.mosad.seil0.projectlaogai.uicomponents
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.cardview.widget.CardView
|
||||
import kotlinx.android.synthetic.main.cardview_day.view.*
|
||||
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
|
||||
class DayCardView(context: Context) : CardView(context) {
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.mensaday_cardview,this)
|
||||
|
||||
linLayoutMensaDay = findViewById(R.id.linLayout_MensaDay)
|
||||
txtViewDayHeading = findViewById(R.id.txtView_DayHeading)
|
||||
inflate(context, R.layout.cardview_day,this)
|
||||
|
||||
// workaround to prevent a white border
|
||||
this.setBackgroundColor(Color.TRANSPARENT)
|
||||
}
|
||||
|
||||
fun getLinLayoutMensaDay(): LinearLayout {
|
||||
return linLayoutMensaDay
|
||||
fun getLinLayoutDay() : LinearLayout {
|
||||
return linLayout_Day
|
||||
}
|
||||
|
||||
fun setDayHeading(heading: String) {
|
||||
txtViewDayHeading.text = heading
|
||||
txtView_DayHeading.text = heading
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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.uicomponents
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.cardview.widget.CardView
|
||||
import kotlinx.android.synthetic.main.linearlayout_lesson.view.*
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.Lesson
|
||||
|
||||
class LessonLinearLayout(context: Context?) : LinearLayout(context) {
|
||||
|
||||
init {
|
||||
CardView.inflate(context, R.layout.linearlayout_lesson, this)
|
||||
}
|
||||
|
||||
fun setLesson(lesson: Lesson, time: String) {
|
||||
txtView_lessonTime.text = time
|
||||
txtView_lessonSubject.text = lesson.lessonSubject
|
||||
txtView_lessonTeacher.text = lesson.lessonTeacher
|
||||
txtView_lessonRoom.text = lesson.lessonRoom
|
||||
}
|
||||
|
||||
fun disableDivider() {
|
||||
divider_lesson.visibility = View.GONE
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package org.mosad.seil0.projectlaogai.uicomponents
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.widget.TextView
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.Lesson
|
||||
|
||||
class LessonTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : TextView(context, attrs) {
|
||||
|
||||
init {
|
||||
this.setTextColor(Color.BLACK)
|
||||
this.textSize = 16F
|
||||
this.setPadding(0,6,0,0)
|
||||
}
|
||||
|
||||
fun setLesson(lesson: Lesson) {
|
||||
this.text = resources.getString(R.string.string_new_line, lesson.lessonSubject)
|
||||
this.append(lesson.lessonTeacher + "\n")
|
||||
this.append(lesson.lessonRoom)
|
||||
}
|
||||
|
||||
fun setText(text: String) {
|
||||
this.text = text
|
||||
}
|
||||
}
|
@ -23,32 +23,32 @@
|
||||
package org.mosad.seil0.projectlaogai.uicomponents
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.cardview.widget.CardView
|
||||
import kotlinx.android.synthetic.main.linearlayout_lesson.view.*
|
||||
import kotlinx.android.synthetic.main.linearlayout_meal.view.*
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.Meal
|
||||
|
||||
class LessonCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
|
||||
|
||||
private var linLayoutLesson: LinearLayout
|
||||
private var txtViewTime: TextView
|
||||
class MealLinearLayout(context: Context?): LinearLayout(context) {
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.lesson_cardview,this)
|
||||
|
||||
linLayoutLesson = findViewById(R.id.linLayout_Lesson)
|
||||
txtViewTime = findViewById(R.id.txtView_Time)
|
||||
|
||||
// workaround to prevent a white border
|
||||
this.setBackgroundColor(Color.TRANSPARENT)
|
||||
CardView.inflate(context, R.layout.linearlayout_meal, this)
|
||||
}
|
||||
|
||||
fun getLinLayoutLesson(): LinearLayout {
|
||||
return linLayoutLesson
|
||||
fun setMeal(meal: Meal) {
|
||||
txtView_MealHeading.text = meal.heading
|
||||
|
||||
meal.parts.forEachIndexed { partIndex, part ->
|
||||
txtView_Meal.append(part)
|
||||
if(partIndex < (meal.parts.size - 1))
|
||||
txtView_Meal.append("\n")
|
||||
}
|
||||
}
|
||||
|
||||
fun getTxtViewTime(): TextView {
|
||||
return txtViewTime
|
||||
fun disableDivider() {
|
||||
divider_meal.visibility = View.GONE
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package org.mosad.seil0.projectlaogai.uicomponents
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.widget.TextView
|
||||
import org.mosad.seil0.projectlaogai.R
|
||||
|
||||
class MenuCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
|
||||
|
||||
private var txtViewMenuHeading: TextView
|
||||
private var txtViewMenu: TextView
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.menu_cardview,this)
|
||||
|
||||
txtViewMenuHeading = findViewById(R.id.txtView_MenuHeading)
|
||||
txtViewMenu = findViewById(R.id.txtView_Menu)
|
||||
|
||||
// workaround to prevent a white border
|
||||
this.setBackgroundColor(Color.TRANSPARENT)
|
||||
}
|
||||
|
||||
fun setMenuHeading(heading: String) {
|
||||
txtViewMenuHeading.text = heading
|
||||
}
|
||||
|
||||
fun getTxtViewMenu(): TextView {
|
||||
return txtViewMenu
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user