the homescreen now shows the next day with a lecture
* fixed getTomorrowWeekIndex() since it would return 7 which is out of the arrays bounds * minor clean up
This commit is contained in:
parent
e51a80b78d
commit
750a808fbe
|
@ -13,7 +13,7 @@ android {
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 11
|
versionCode 11
|
||||||
versionName "0.3.97"
|
versionName "0.3.98"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
resValue "string", "build_time", buildTime()
|
resValue "string", "build_time", buildTime()
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,8 +174,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||||
cal.time = Date(timetableCacheTime * 1000)
|
cal.time = Date(timetableCacheTime * 1000)
|
||||||
val timetableCacheDay = cal.get(Calendar.DAY_OF_WEEK)
|
val timetableCacheDay = cal.get(Calendar.DAY_OF_WEEK)
|
||||||
|
|
||||||
// if the last update was on moday and now its a sunday, update before displaying the timetable
|
// if the last update was on monday and now its a sunday, update before displaying the timetable
|
||||||
// TODO this sill backfire if someone has to update before the server finished updateing the timetable at 0001/0101
|
// TODO this sill backfire if someone has to update before the server finished updating the timetable at 0001/0101
|
||||||
if(currentDay == Calendar.MONDAY && timetableCacheDay == Calendar.SUNDAY) {
|
if(currentDay == Calendar.MONDAY && timetableCacheDay == Calendar.SUNDAY) {
|
||||||
println("updating timetable after sunday!")
|
println("updating timetable after sunday!")
|
||||||
val jobA = tcor.getTimetable(cCourse.courseName, 0)
|
val jobA = tcor.getTimetable(cCourse.courseName, 0)
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timeta
|
||||||
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
|
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
|
||||||
import org.mosad.seil0.projectlaogai.hsoparser.Meal
|
import org.mosad.seil0.projectlaogai.hsoparser.Meal
|
||||||
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
|
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
|
||||||
|
import org.mosad.seil0.projectlaogai.hsoparser.TimetableDay
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.LessonLinearLayout
|
import org.mosad.seil0.projectlaogai.uicomponents.LessonLinearLayout
|
||||||
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
||||||
|
@ -52,13 +53,13 @@ import java.util.*
|
||||||
*/
|
*/
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
|
|
||||||
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY)
|
private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
val view: View = inflater.inflate(R.layout.fragment_home, container, false)
|
val view: View = inflater.inflate(R.layout.fragment_home, container, false)
|
||||||
|
|
||||||
addMensaMenu()
|
addMensaMenu().get()
|
||||||
addTimeTable()
|
addTimeTable()
|
||||||
|
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
|
@ -68,56 +69,46 @@ class HomeFragment : Fragment() {
|
||||||
/**
|
/**
|
||||||
* add the current mensa meal to the home screens
|
* add the current mensa meal to the home screens
|
||||||
*/
|
*/
|
||||||
private fun addMensaMenu() {
|
private fun addMensaMenu() = doAsync {
|
||||||
doAsync {
|
|
||||||
|
|
||||||
var dayMeals: ArrayList<Meal>
|
var dayMeals: ArrayList<Meal>
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
val mensaCardView = DayCardView(context!!)
|
val mensaCardView = DayCardView(context!!)
|
||||||
|
|
||||||
uiThread {
|
uiThread {
|
||||||
|
|
||||||
if (cal.get(Calendar.HOUR_OF_DAY) < 15) {
|
if (cal.get(Calendar.HOUR_OF_DAY) < 15) {
|
||||||
dayMeals = mensaCurrentWeek.days[NotRetardedCalendar().getDayOfWeekIndex()].meals
|
dayMeals = mensaCurrentWeek.days[NotRetardedCalendar().getDayOfWeekIndex()].meals
|
||||||
mensaCardView.setDayHeading(resources.getString(R.string.today_date, formatter.format(cal.time)))
|
mensaCardView.setDayHeading(resources.getString(R.string.today_date, formatter.format(cal.time)))
|
||||||
} else {
|
} else {
|
||||||
dayMeals = mensaCurrentWeek.days[NotRetardedCalendar().getTomorrowWeekIndex()].meals
|
dayMeals = mensaCurrentWeek.days[NotRetardedCalendar().getTomorrowWeekIndex()].meals
|
||||||
cal.add(Calendar.DATE, 1)
|
cal.add(Calendar.DATE, 1)
|
||||||
mensaCardView.setDayHeading(resources.getString(R.string.tomorrow_date, formatter.format(cal.time)))
|
mensaCardView.setDayHeading(resources.getString(R.string.tomorrow_date, formatter.format(cal.time)))
|
||||||
}
|
|
||||||
|
|
||||||
if (dayMeals.size >= 2) {
|
|
||||||
// get the index of the first meal, not a "Schneller Teller"
|
|
||||||
loop@ for ((i, meal) in dayMeals.withIndex()) {
|
|
||||||
if (meal.heading.contains("Essen")) {
|
|
||||||
|
|
||||||
val meal1Layout = MealLinearLayout(context)
|
|
||||||
meal1Layout.setMeal(dayMeals[i])
|
|
||||||
mensaCardView.getLinLayoutDay().addView(meal1Layout)
|
|
||||||
|
|
||||||
val meal2Layout = MealLinearLayout(context)
|
|
||||||
meal2Layout.setMeal(dayMeals[i + 1])
|
|
||||||
meal2Layout.disableDivider()
|
|
||||||
mensaCardView.getLinLayoutDay().addView(meal2Layout)
|
|
||||||
|
|
||||||
break@loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
val noFood = TextView(context)
|
|
||||||
noFood.text = resources.getString(R.string.mensa_closed)
|
|
||||||
noFood.setTextColor(ContextCompat.getColor(context!!, R.color.textPrimary))
|
|
||||||
noFood.textSize = 18.0F
|
|
||||||
noFood.setTypeface(null, Typeface.BOLD)
|
|
||||||
noFood.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
|
||||||
noFood.setPadding(7,7,7,7)
|
|
||||||
|
|
||||||
mensaCardView.getLinLayoutDay().addView(noFood)
|
|
||||||
}
|
|
||||||
|
|
||||||
linLayout_Home.addView(mensaCardView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dayMeals.size >= 2) {
|
||||||
|
// get the index of the first meal, not a "Schneller Teller"
|
||||||
|
loop@ for ((i, meal) in dayMeals.withIndex()) {
|
||||||
|
if (meal.heading.contains("Essen")) {
|
||||||
|
|
||||||
|
val meal1Layout = MealLinearLayout(context)
|
||||||
|
meal1Layout.setMeal(dayMeals[i])
|
||||||
|
mensaCardView.getLinLayoutDay().addView(meal1Layout)
|
||||||
|
|
||||||
|
val meal2Layout = MealLinearLayout(context)
|
||||||
|
meal2Layout.setMeal(dayMeals[i + 1])
|
||||||
|
meal2Layout.disableDivider()
|
||||||
|
mensaCardView.getLinLayoutDay().addView(meal2Layout)
|
||||||
|
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mensaCardView.getLinLayoutDay().addView(getNoCard(resources.getString(R.string.mensa_closed)))
|
||||||
|
}
|
||||||
|
|
||||||
|
linLayout_Home.addView(mensaCardView)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -125,67 +116,104 @@ class HomeFragment : Fragment() {
|
||||||
/**
|
/**
|
||||||
* add the current timetable to the home screen
|
* add the current timetable to the home screen
|
||||||
*/
|
*/
|
||||||
private fun addTimeTable() {
|
private fun addTimeTable() = doAsync {
|
||||||
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
||||||
var helpLesson = LessonLinearLayout(context!!)
|
val cal = Calendar.getInstance()
|
||||||
val dayCardView = DayCardView(context!!)
|
var dayCardView = DayCardView(context!!)
|
||||||
dayCardView.setDayHeading(resources.getString(R.string.today_date, formatter.format(Calendar.getInstance().time)))
|
|
||||||
|
|
||||||
doAsync {
|
uiThread {
|
||||||
uiThread {
|
|
||||||
|
|
||||||
if (timetables[0].days.isNotEmpty() && dayIndex < 6) {
|
if (timetables.isNotEmpty() && dayIndex < 6) {
|
||||||
|
|
||||||
// for all timeslots of the day
|
// first check the current day
|
||||||
for ((tsIndex, timeslot) in timetables[0].days[dayIndex].timeslots.withIndex()) {
|
dayCardView = addDayTimetable(timetables[0].days[dayIndex])
|
||||||
|
dayCardView.setDayHeading(resources.getString(R.string.today_date, formatter.format(cal.time)))
|
||||||
|
|
||||||
for(lesson in timeslot) {
|
// if there are no lessons don't show the dayCardView
|
||||||
if(lesson.lessonSubject.isNotEmpty()) {
|
if (dayCardView.getLinLayoutDay().childCount <= 1) {
|
||||||
|
// get next day with at least one lecture
|
||||||
|
var dayTimetable: TimetableDay? = null
|
||||||
|
var weekIndex = 0
|
||||||
|
var dayIndexSearch = dayIndex + 1
|
||||||
|
loop@ while (dayTimetable == null && weekIndex <= timetables.size) {
|
||||||
|
for (i in (dayIndexSearch) ..5) {
|
||||||
|
dayTimetable = timetables[weekIndex].days[i]
|
||||||
|
cal.add(Calendar.DATE, 1)
|
||||||
|
|
||||||
val lessonLayout = LessonLinearLayout(context!!)
|
// add the timetable to the card, if it contains at least one lesson break!
|
||||||
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
dayCardView = addDayTimetable(dayTimetable)
|
||||||
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
dayCardView.setDayHeading(formatter.format(cal.time))
|
||||||
|
|
||||||
if (lesson != timeslot.last()) {
|
if (dayCardView.getLinLayoutDay().childCount > 1)
|
||||||
lessonLayout.disableDivider()
|
break@loop
|
||||||
}
|
|
||||||
|
|
||||||
helpLesson = lessonLayout
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
dayIndexSearch = 0
|
||||||
|
weekIndex++
|
||||||
|
cal.add(Calendar.DATE, 1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
helpLesson.disableDivider()
|
if (dayCardView.getLinLayoutDay().childCount <= 1)
|
||||||
// if there are no lessons don't show the dayCardView
|
dayCardView.getLinLayoutDay().addView(getNoCard(resources.getString(R.string.no_lesson_today))) // if there is no lecture at all show the no lesson card
|
||||||
if (dayCardView.getLinLayoutDay().childCount > 1) {
|
|
||||||
linLayout_Home.addView(dayCardView)
|
|
||||||
} else {
|
|
||||||
// TODO we could display the next day with a lecture
|
|
||||||
val noLesson = DayCardView(context!!)
|
|
||||||
noLesson.setDayHeading(resources.getString(R.string.no_lesson_today))
|
|
||||||
|
|
||||||
linLayout_Home.addView(noLesson)
|
linLayout_Home.addView(dayCardView)
|
||||||
}
|
} else {
|
||||||
|
if (dayIndex == 6) {
|
||||||
|
// TODO iss this necessary?
|
||||||
|
// if that's the case it's sunday
|
||||||
|
dayCardView.getLinLayoutDay().addView(getNoCard(resources.getString(R.string.no_lesson_today)))
|
||||||
|
linLayout_Home.addView(dayCardView)
|
||||||
} else {
|
} else {
|
||||||
if (dayIndex == 6) {
|
MaterialDialog(context!!)
|
||||||
// if that's the case it's sunday
|
.title(R.string.error)
|
||||||
val noLesson = DayCardView(context!!)
|
.message(R.string.gen_tt_error)
|
||||||
noLesson.setDayHeading(resources.getString(R.string.no_lesson_today))
|
.show()
|
||||||
|
// TODO log the error and send feedback
|
||||||
linLayout_Home.addView(noLesson)
|
|
||||||
} else {
|
|
||||||
MaterialDialog(context!!)
|
|
||||||
.title(R.string.error)
|
|
||||||
.message(R.string.gen_tt_error)
|
|
||||||
.show()
|
|
||||||
// TODO log the error and send feedback
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addDayTimetable(dayTimetable: TimetableDay) : DayCardView{
|
||||||
|
var helpLesson = LessonLinearLayout(context)
|
||||||
|
val dayCardView = DayCardView(context!!)
|
||||||
|
|
||||||
|
for ((tsIndex, timeslot) in dayTimetable.timeslots.withIndex()) {
|
||||||
|
|
||||||
|
for(lesson in timeslot) {
|
||||||
|
if(lesson.lessonSubject.isNotEmpty()) {
|
||||||
|
|
||||||
|
val lessonLayout = LessonLinearLayout(context)
|
||||||
|
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
||||||
|
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
||||||
|
|
||||||
|
if (lesson != timeslot.last()) {
|
||||||
|
lessonLayout.disableDivider()
|
||||||
|
}
|
||||||
|
|
||||||
|
helpLesson = lessonLayout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helpLesson.disableDivider()
|
||||||
|
|
||||||
|
return dayCardView
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getNoCard(text: String): TextView {
|
||||||
|
val noLesson = TextView(context)
|
||||||
|
noLesson.text = text
|
||||||
|
noLesson.setTextColor(ContextCompat.getColor(context!!, R.color.textPrimary))
|
||||||
|
noLesson.textSize = 18.0F
|
||||||
|
noLesson.setTypeface(null, Typeface.BOLD)
|
||||||
|
noLesson.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||||
|
noLesson.setPadding(7,7,7,7)
|
||||||
|
|
||||||
|
return noLesson
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,10 @@ class MensaFragment : Fragment() {
|
||||||
|
|
||||||
// add the current week (week starts on sunday)
|
// add the current week (week starts on sunday)
|
||||||
val dayCurrent = if(NotRetardedCalendar().getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar().getDayOfWeekIndex()
|
val dayCurrent = if(NotRetardedCalendar().getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar().getDayOfWeekIndex()
|
||||||
addWeek(mensaCurrentWeek, dayCurrent)
|
addWeek(mensaCurrentWeek, dayCurrent).get()
|
||||||
|
|
||||||
// add the next week
|
// add the next week
|
||||||
addWeek(mensaNextWeek, 0)
|
addWeek(mensaNextWeek, 0).get()
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
@ -67,41 +67,32 @@ class MensaFragment : Fragment() {
|
||||||
/**
|
/**
|
||||||
* add all menus from dayStart to Friday for a given week
|
* add all menus from dayStart to Friday for a given week
|
||||||
*/
|
*/
|
||||||
private fun addWeek(menusWeek: MensaWeek, dayStart: Int) {
|
private fun addWeek(menusWeek: MensaWeek, dayStart: Int) = doAsync {
|
||||||
|
|
||||||
doAsync {
|
uiThread {
|
||||||
|
|
||||||
uiThread {
|
// only add the days dayStart to Fri since the mensa is closed on Sat/Sun
|
||||||
|
for (dayIndex in dayStart..4) {
|
||||||
|
var helpMeal = MealLinearLayout(context)
|
||||||
|
val dayCardView = DayCardView(context!!)
|
||||||
|
dayCardView.setDayHeading(menusWeek.days[dayIndex].meals[0].day)
|
||||||
|
|
||||||
// only add the days dayStart to Fri since the mensa is closed on Sat/Sun
|
for (meal in menusWeek.days[dayIndex].meals) {
|
||||||
for (dayIndex in dayStart..4) {
|
val mealLayout = MealLinearLayout(context)
|
||||||
var helpMeal = MealLinearLayout(context)
|
mealLayout.setMeal(meal)
|
||||||
val dayCardView = DayCardView(context!!)
|
|
||||||
dayCardView.setDayHeading(menusWeek.days[dayIndex].meals[0].day)
|
|
||||||
|
|
||||||
for (meal in menusWeek.days[dayIndex].meals) {
|
if(meal.heading != "Buffet" || cShowBuffet) {
|
||||||
val mealLayout = MealLinearLayout(context)
|
dayCardView.getLinLayoutDay().addView(mealLayout)
|
||||||
mealLayout.setMeal(meal)
|
helpMeal = mealLayout
|
||||||
|
|
||||||
if(meal.heading != "Buffet" || cShowBuffet) {
|
|
||||||
dayCardView.getLinLayoutDay().addView(mealLayout)
|
|
||||||
helpMeal = mealLayout
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
helpMeal.disableDivider()
|
|
||||||
|
|
||||||
if(dayCardView.getLinLayoutDay().childCount > 1)
|
|
||||||
linLayoutMensaFragment.addView(dayCardView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a card if there are no more meals in this week
|
helpMeal.disableDivider()
|
||||||
if(linLayoutMensaFragment.childCount == 0) {
|
|
||||||
val noFood = DayCardView(context!!)
|
if(dayCardView.getLinLayoutDay().childCount > 1)
|
||||||
noFood.setDayHeading(resources.getString(R.string.no_more_food))
|
linLayout_Mensa.addView(dayCardView)
|
||||||
linLayout_Mensa.addView(noFood)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,91 +60,84 @@ class TimeTableFragment : Fragment() {
|
||||||
/**
|
/**
|
||||||
* add the all days with at least one lesson to the timetable screen
|
* add the all days with at least one lesson to the timetable screen
|
||||||
*/
|
*/
|
||||||
private fun addWeeks() {
|
private fun addWeeks() = doAsync {
|
||||||
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
|
||||||
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24
|
val formatter = SimpleDateFormat("E dd.MM", Locale.GERMANY) // TODO change to android call when min api is 24
|
||||||
val calendar = Calendar.getInstance()
|
val calendar = Calendar.getInstance()
|
||||||
|
|
||||||
doAsync {
|
uiThread {
|
||||||
|
|
||||||
uiThread {
|
// add the current week
|
||||||
|
for (day in dayIndex..5) {
|
||||||
|
var helpLesson = LessonLinearLayout(context)
|
||||||
|
val dayCardView = DayCardView(context!!)
|
||||||
|
dayCardView.setDayHeading(formatter.format(calendar.time))
|
||||||
|
|
||||||
// add the current week
|
// for each timeslot of the day
|
||||||
for (day in dayIndex..5) {
|
for ((tsIndex, timeslot) in timetables[0].days[day].timeslots.withIndex()) {
|
||||||
var helpLesson = LessonLinearLayout(context)
|
|
||||||
val dayCardView = DayCardView(context!!)
|
|
||||||
dayCardView.setDayHeading(formatter.format(calendar.time))
|
|
||||||
|
|
||||||
// for each timeslot of the day
|
for(lesson in timeslot) {
|
||||||
for ((tsIndex, timeslot) in timetables[0].days[day].timeslots.withIndex()) {
|
|
||||||
|
|
||||||
for(lesson in timeslot) {
|
if(lesson.lessonSubject.isNotEmpty()) {
|
||||||
|
|
||||||
if(lesson.lessonSubject.isNotEmpty()) {
|
val lessonLayout = LessonLinearLayout(context)
|
||||||
|
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
||||||
|
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
||||||
|
|
||||||
val lessonLayout = LessonLinearLayout(context)
|
if (lesson != timeslot.last())
|
||||||
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
lessonLayout.disableDivider()
|
||||||
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
|
||||||
|
|
||||||
if (lesson != timeslot.last()) {
|
helpLesson = lessonLayout
|
||||||
lessonLayout.disableDivider()
|
|
||||||
}
|
|
||||||
|
|
||||||
helpLesson = lessonLayout
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
helpLesson.disableDivider()
|
|
||||||
calendar.add(Calendar.DATE, 1)
|
|
||||||
|
|
||||||
// if there are no lessons don't show the dayCardView
|
|
||||||
if (dayCardView.getLinLayoutDay().childCount > 1) {
|
|
||||||
linLayout_Timetable.addView(dayCardView)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helpLesson.disableDivider()
|
||||||
|
calendar.add(Calendar.DATE, 1)
|
||||||
|
|
||||||
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
|
// if there are no lessons don't show the dayCardView
|
||||||
|
if (dayCardView.getLinLayoutDay().childCount > 1)
|
||||||
// add the next week
|
linLayout_Timetable.addView(dayCardView)
|
||||||
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 ((tsIndex, timeslot) in timetables[1].days[day].timeslots.withIndex()) {
|
|
||||||
|
|
||||||
for(lesson in timeslot) {
|
|
||||||
|
|
||||||
if(lesson.lessonSubject.isNotEmpty()) {
|
|
||||||
|
|
||||||
val lessonLayout = LessonLinearLayout(context!!)
|
|
||||||
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
|
||||||
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
|
||||||
|
|
||||||
if (lesson != timeslot.last()) {
|
|
||||||
lessonLayout.disableDivider()
|
|
||||||
}
|
|
||||||
|
|
||||||
helpLesson = lessonLayout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
helpLesson.disableDivider()
|
|
||||||
calendar.add(Calendar.DATE, 1)
|
|
||||||
|
|
||||||
// if there are no lessons don't show the dayCardView
|
|
||||||
if (dayCardView.getLinLayoutDay().childCount > 1) {
|
|
||||||
linLayout_Timetable.addView(dayCardView)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calendar.add(Calendar.DATE, 1) // before this we are at a sunday (no lecture on sundays!)
|
||||||
|
|
||||||
|
// 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 ((tsIndex, timeslot) in timetables[1].days[day].timeslots.withIndex()) {
|
||||||
|
|
||||||
|
for(lesson in timeslot) {
|
||||||
|
|
||||||
|
if(lesson.lessonSubject.isNotEmpty()) {
|
||||||
|
|
||||||
|
val lessonLayout = LessonLinearLayout(context!!)
|
||||||
|
lessonLayout.setLesson(lesson, DataTypes().getTime()[tsIndex])
|
||||||
|
dayCardView.getLinLayoutDay().addView(lessonLayout)
|
||||||
|
|
||||||
|
if (lesson != timeslot.last())
|
||||||
|
lessonLayout.disableDivider()
|
||||||
|
|
||||||
|
helpLesson = lessonLayout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helpLesson.disableDivider()
|
||||||
|
calendar.add(Calendar.DATE, 1)
|
||||||
|
|
||||||
|
// if there are no lessons don't show the dayCardView
|
||||||
|
if (dayCardView.getLinLayoutDay().childCount > 1)
|
||||||
|
linLayout_Timetable.addView(dayCardView)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,14 +98,14 @@ class NotRetardedCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTomorrowWeekIndex(): Int {
|
fun getTomorrowWeekIndex(): Int {
|
||||||
return when(calendar.get(Calendar.DAY_OF_WEEK) + 1) {
|
return when(calendar.get(Calendar.DAY_OF_WEEK)) {
|
||||||
Calendar.MONDAY -> 0
|
Calendar.MONDAY -> 1
|
||||||
Calendar.TUESDAY -> 1
|
Calendar.TUESDAY -> 2
|
||||||
Calendar.WEDNESDAY -> 2
|
Calendar.WEDNESDAY -> 2
|
||||||
Calendar.THURSDAY -> 3
|
Calendar.THURSDAY -> 4
|
||||||
Calendar.FRIDAY -> 4
|
Calendar.FRIDAY -> 5
|
||||||
Calendar.SATURDAY -> 5
|
Calendar.SATURDAY -> 6
|
||||||
Calendar.SUNDAY -> 6
|
Calendar.SUNDAY -> 0
|
||||||
else -> 7
|
else -> 7
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item
|
<item android:drawable="@color/colorPrimary"/>
|
||||||
android:drawable="@color/colorPrimary"/>
|
|
||||||
|
|
||||||
<!--TODO when minAPI is 23 use this-->
|
<!--TODO when minAPI is 23 use this-->
|
||||||
<!--<item android:gravity="center" android:width="144dp" android:height="144dp">-->
|
<!--<item android:gravity="center" android:width="144dp" android:height="144dp">-->
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragments.HomeFragment">
|
tools:context=".fragments.HomeFragment">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".fragments.MensaFragment">
|
tools:context=".fragments.MensaFragment">
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
android:layout_height="match_parent" android:id="@+id/linLayout_Meal" android:padding="7dp">
|
android:layout_height="match_parent" android:id="@+id/linLayout_Meal" android:padding="7dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/meal_1"
|
android:text="@string/meal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" android:id="@+id/txtView_MealHeading" android:textSize="18sp"
|
android:layout_height="wrap_content" android:id="@+id/txtView_MealHeading" android:textSize="18sp"
|
||||||
android:textColor="@color/textPrimary" android:textAlignment="center" android:paddingBottom="5dp"
|
android:textColor="@color/textPrimary" android:textAlignment="center" android:paddingBottom="5dp"
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
<string name="timetable">Stundenplan</string>
|
<string name="timetable">Stundenplan</string>
|
||||||
<string name="moodle">Moodle</string>
|
<string name="moodle">Moodle</string>
|
||||||
<string name="settings">Einstellungen</string>
|
<string name="settings">Einstellungen</string>
|
||||||
<string name="meal_1">Essen 1</string>
|
<string name="meal">Essen</string>
|
||||||
<string name="meal_2">Essen 2</string>
|
|
||||||
<string name="today_date">Heute, %1$s</string>
|
<string name="today_date">Heute, %1$s</string>
|
||||||
<string name="tomorrow_date">Morgen, %1$s</string>
|
<string name="tomorrow_date">Morgen, %1$s</string>
|
||||||
<string name="mensa_closed">keine Essensausgabe</string>
|
<string name="mensa_closed">keine Essensausgabe</string>
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
<string name="moodle">Moodle</string>
|
<string name="moodle">Moodle</string>
|
||||||
<string name="settings">Settings</string>
|
<string name="settings">Settings</string>
|
||||||
|
|
||||||
<string name="meal_1">Meal 1</string>
|
<string name="meal">Meal</string>
|
||||||
<string name="meal_2">Meal 2</string>
|
|
||||||
<string name="today_date">Today, %1$s</string>
|
<string name="today_date">Today, %1$s</string>
|
||||||
<string name="tomorrow_date">Tomorrow, %1$s</string>
|
<string name="tomorrow_date">Tomorrow, %1$s</string>
|
||||||
<string name="mensa_closed">the Mensa is closed</string>
|
<string name="mensa_closed">the Mensa is closed</string>
|
||||||
|
@ -27,7 +26,6 @@
|
||||||
<string name="sample_user" translatable="false">SampleUser@stud.hs-offenburg.de</string>
|
<string name="sample_user" translatable="false">SampleUser@stud.hs-offenburg.de</string>
|
||||||
<string name="sample_course" translatable="false">SampleCourse 3</string>
|
<string name="sample_course" translatable="false">SampleCourse 3</string>
|
||||||
<string name="sample_date" translatable="false">Montag, 30.02</string>
|
<string name="sample_date" translatable="false">Montag, 30.02</string>
|
||||||
<string name="a_lesson" translatable="false">a lesson\na teacher\na room</string>
|
|
||||||
<string name="a_time" translatable="false">0.00 – 23.59</string>
|
<string name="a_time" translatable="false">0.00 – 23.59</string>
|
||||||
|
|
||||||
<string name="info">Info</string>
|
<string name="info">Info</string>
|
||||||
|
@ -46,8 +44,6 @@
|
||||||
<string name="about_dialog_text" translatable="false">"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018-2019 seil0@mosad.xyz "</string>
|
<string name="about_dialog_text" translatable="false">"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018-2019 seil0@mosad.xyz "</string>
|
||||||
<string name="loading_timetable">loading timetable …</string>
|
<string name="loading_timetable">loading timetable …</string>
|
||||||
|
|
||||||
<string name="string_new_line" translatable="false">%1$s\n</string>
|
|
||||||
|
|
||||||
<string name="save_key_course" translatable="false">org.mosad.seil0.projectlaogai.course</string>
|
<string name="save_key_course" translatable="false">org.mosad.seil0.projectlaogai.course</string>
|
||||||
<string name="save_key_courseTTLink" translatable="false">org.mosad.seil0.projectlaogai.courseTTLink</string>
|
<string name="save_key_courseTTLink" translatable="false">org.mosad.seil0.projectlaogai.courseTTLink</string>
|
||||||
<string name="save_key_colorPrimary" translatable="false">org.mosad.seil0.projectlaogai.colorPrimary</string>
|
<string name="save_key_colorPrimary" translatable="false">org.mosad.seil0.projectlaogai.colorPrimary</string>
|
||||||
|
|
Loading…
Reference in New Issue