@ -62,28 +62,23 @@ class TimeTableFragment : Fragment() {
/ * *
* add the remaining days of the current week to the timetable screen
* TODO show the current day and the following 5 days
* /
private fun addCurrentWeek ( ) {
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 ( )
doAsync {
uiThread {
println ( dayIndex )
// add current weeks days
for ( day in dayIndex .. 5 ) {
val formatter = SimpleDateFormat ( " E dd.MM " , Locale . GERMANY ) // TODO change to android call when min api is 24
val calendar = Calendar . getInstance ( )
calendar . firstDayOfWeek = Calendar . MONDAY
calendar . add ( Calendar . DATE , day - Calendar . getInstance ( ) . get ( Calendar . DAY _OF _WEEK ) )
val cardViewTimeTableDay = MensaDayCardView ( context !! , null )
cardViewTimeTableDay . setDayHeading ( formatter . format ( calendar . time ) )
// for each lessen of the day
for ( ( i , lesson ) in mainActivity . getCurrent TimeTableWeek ( ) [ dayIndex ] . withIndex ( ) ) {
for ( ( i , lesson ) in mainActivity . getTimeTableCurrentWeek ( ) [ day ] . withIndex ( ) ) {
val lessonCardView = LessonCardView ( context !! , null )
lessonCardView . setBackgroundColor ( Color . TRANSPARENT )
@ -96,11 +91,39 @@ class TimeTableFragment : Fragment() {
cardViewTimeTableDay . getLinLayoutMensaDay ( ) . addView ( lessonCardView )
}
// TODO if there is no lesson at one day , show a no lesson card
calendar . add ( Calendar . DATE , 1 )
linLayoutTTFragment . addView ( cardViewTimeTableDay )
}
// add next weeks days, max number = dayIndex, if timetable was loaded
if ( mainActivity . getTimeTableNextWeek ( ) . isNotEmpty ( ) ) {
calendar . add ( Calendar . DATE , 1 ) // before this we are at a sunday (no lecture on sundays!)
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 . getTimeTableNextWeek ( ) [ day ] . withIndex ( ) ) {
val lessonCardView = LessonCardView ( context !! , null )
lessonCardView . setBackgroundColor ( Color . TRANSPARENT )
lessonCardView . getTxtViewLesson ( ) . text = resources . getString ( R . string . string _new _line , lesson . lessonSubject )
lessonCardView . getTxtViewLesson ( ) . append ( lesson . lessonTeacher + " \n " )
lessonCardView . getTxtViewLesson ( ) . append ( lesson . lessonRoom )
lessonCardView . getTxtViewTime ( ) . text = DataTypes ( ) . getTime ( ) [ i ]
if ( lessonCardView . getTxtViewLesson ( ) . text . length > 2 )
cardViewTimeTableDay . getLinLayoutMensaDay ( ) . addView ( lessonCardView )
}
calendar . add ( Calendar . DATE , 1 )
linLayoutTTFragment . addView ( cardViewTimeTableDay )
}
}
// TODO if there is no lesson at one day , show a no lesson card
}
}