@ -22,7 +22,6 @@
package org.mosad.seil0.projectlaogai.fragments
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -37,6 +36,7 @@ import org.mosad.seil0.projectlaogai.R
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 java.text.SimpleDateFormat
import java.util.*
@ -83,38 +83,41 @@ class TimeTableFragment : Fragment() {
// for each timeslot of the day
for ( ( i , timeslot ) in cTimeTableCurrentWeek . days [ day ] . timeslots . withIndex ( ) ) {
val lessonCardView = LessonCardView ( context !! , null )
lessonCardView . getTxtViewTime ( ) . text = DataTypes ( ) . getTime ( ) [ i ]
println ( timeslot )
//println(timeslot )
for ( lesson in timeslot ) {
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 ]
val lessonTxtView = LessonTextView ( context !! )
lessonTxtView . setLesson ( lesson )
// only add the lesson if it contains data
if ( lessonCardView . get TxtViewLesson ( ) . text . length > 2 )
cardViewTimeTableDay . getLinLayoutMensaDay ( ) . addView ( lessonCard View )
// TODO why does this exist
if ( lessonTxtView . text . length > 3 )
lessonCardView . getLinLayoutLesson ( ) . addView ( lessonTxtView )
}
// only add the lesson if it contains data
if ( lessonCardView . getLinLayoutLesson ( ) . childCount > 1 )
cardViewTimeTableDay . getLinLayoutMensaDay ( ) . addView ( lessonCardView )
}
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 . setBackgroundColor ( Color . TRANSPARENT )
lessonCardView . getTxtViewLesson ( ) . text = resources . getString ( R . string . no _lesson _today )
lessonCardView . getLinLayoutLesson ( ) . addView ( lessonTxtView )
cardViewTimeTableDay . getLinLayoutMensaDay ( ) . addView ( lessonCardView )
}
linLayoutTTFragment . addView ( cardViewTimeTableDay )
}
// TODO if there is no lesson at one day , show a no lesson card
// add next weeks days, max number = dayIndex, if timetable was loaded
if ( cTimeTableNextWeek . days . isNotEmpty ( ) ) {
calendar . add ( Calendar . DATE , 1 ) // before this we are at a sunday (no lecture on sundays!)
@ -126,23 +129,36 @@ class TimeTableFragment : Fragment() {
// for each timeslot of the day
for ( ( i , timeslot ) in cTimeTableNextWeek . days [ day ] . timeslots . withIndex ( ) ) {
val lessonCardView = LessonCardView ( context !! , null )
lessonCardView . getTxtViewTime ( ) . text = DataTypes ( ) . getTime ( ) [ i ]
for ( lesson in timeslot ) {
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 ]
for ( lesson in timeslot ) {
val lessonTxtView = LessonTextView ( context !! )
lessonTxtView . setLesson ( lesson )
// only add the lesson if it contains data
if ( lessonCardView . getTxtViewLesson ( ) . text . length > 2 )
cardViewTimeTableDay . getLinLayoutMensaDay ( ) . addView ( lessonCardView )
if ( lessonTxtView . text . length > 3 )
lessonCardView . getLinLayoutLesson ( ) . addView ( lessonTxtView )
}
// only add the lesson if it contains data
if ( lessonCardView . getLinLayoutLesson ( ) . childCount > 1 )
cardViewTimeTableDay . getLinLayoutMensaDay ( ) . addView ( lessonCardView )
}
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 )
}
}