version 0.1.2

* fixed a crash that occurred if there was no meal for the current day
* added a card if there's no more meals this week
* added a card if there's no lesson at the current day
This commit is contained in:
2018-11-01 01:06:53 +01:00
parent 9f09fdcff2
commit b915f574fe
8 changed files with 43 additions and 18 deletions

View File

@ -156,4 +156,5 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
timeTableWeek = timeTableParser.getTimeTable("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0")
}.get()
}
}

View File

@ -71,12 +71,18 @@ class HomeFragment : Fragment() {
val dayMenus: ArrayList<Meal> = MensaParser().getMensaMenuDay(currentMenus, 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)
if (dayMenus.size >= 2) {
for(part in dayMenus[0].parts) {
txtViewMenu1.append(part)
}
for(part in dayMenus[1].parts) {
txtViewMenu2.append(part)
}
} else {
txtViewMenu1.text = resources.getString(R.string.no_meal_today)
txtViewMenu2.text = resources.getString(R.string.no_meal_today)
}
}
}
@ -97,6 +103,14 @@ class HomeFragment : Fragment() {
if(lessonCardView.getTxtViewLesson().text.length > 2)
linLayoutTimeTable.addView(lessonCardView)
}
// add a card if there is no lesson today
if (linLayoutTimeTable.childCount == 0) {
// TODO we could display the next day with a lecture
val noLessonCardView = LessonCardView(context!!, null)
noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today) + "\n"
linLayoutTimeTable.addView(noLessonCardView)
}
}
fun setCurrentMenu(weekMenus: ArrayList<Meal>){

View File

@ -99,6 +99,13 @@ class MensaFragment : Fragment() {
if(add)
linLayoutMensaFragment.addView(cardViewMensaDay)
}
// 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)
}
}
}

View File

@ -72,9 +72,8 @@ class MensaParser {
}
for (meal in mealList) {
if (meal.day.contains(strDay)) {
if (meal.day.contains(strDay))
dayMenus.add(meal)
}
}
return dayMenus
}