timetable week view shows the current + the following 5 days, bugfixes
*fixed always showing the same day in week timetable view * fixed wrong date is shown in timetable week view
This commit is contained in:
		@ -11,7 +11,7 @@ android {
 | 
			
		||||
        minSdkVersion 21
 | 
			
		||||
        targetSdkVersion 28
 | 
			
		||||
        versionCode 6
 | 
			
		||||
        versionName "0.2.1"
 | 
			
		||||
        versionName "0.2.2"
 | 
			
		||||
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 | 
			
		||||
    }
 | 
			
		||||
    buildTypes {
 | 
			
		||||
 | 
			
		||||
@ -50,7 +50,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
 | 
			
		||||
 | 
			
		||||
    private var weekMenus = ArrayList<Meal>()
 | 
			
		||||
    private var courseTTLinkList = ArrayList<CourseTTLink>()
 | 
			
		||||
    private var timeTableWeek = arrayOf<Array<Lesson>>()
 | 
			
		||||
    private var timeTableCurrentWeek = arrayOf<Array<Lesson>>()
 | 
			
		||||
    private var timeTableNextWeek = arrayOf<Array<Lesson>>()
 | 
			
		||||
 | 
			
		||||
    private lateinit var course: CourseTTLink
 | 
			
		||||
 | 
			
		||||
@ -163,7 +164,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
 | 
			
		||||
            apply()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
 | 
			
		||||
        timeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("http", "https"))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -192,13 +193,21 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
 | 
			
		||||
                courseTTLinkList = timeTableParser.getCourseTTLinks()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            doAsync {
 | 
			
		||||
                try {
 | 
			
		||||
                    timeTableNextWeek = timeTableParser.getTimeTable(course.courseTTLink.replace("week=0","week=1"))
 | 
			
		||||
                } catch (e: Exception) {
 | 
			
		||||
                    e.stackTrace
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            val t1 = doAsync {
 | 
			
		||||
                weekMenus = mensaParser.getMensaMenu()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            val t2 = doAsync {
 | 
			
		||||
                try {
 | 
			
		||||
                    timeTableWeek = timeTableParser.getTimeTable(course.courseTTLink)
 | 
			
		||||
                    timeTableCurrentWeek = timeTableParser.getTimeTable(course.courseTTLink)
 | 
			
		||||
                } catch (e: Exception) {
 | 
			
		||||
 | 
			
		||||
                    uiThread {
 | 
			
		||||
@ -223,8 +232,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
 | 
			
		||||
        return  courseTTLinkList
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun getCurrentTimeTableWeek(): Array<Array<Lesson>> {
 | 
			
		||||
        return timeTableWeek
 | 
			
		||||
    fun getTimeTableCurrentWeek(): Array<Array<Lesson>> {
 | 
			
		||||
        return timeTableCurrentWeek
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun getTimeTableNextWeek(): Array<Array<Lesson>> {
 | 
			
		||||
        return timeTableNextWeek
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun getWeekMenu(): ArrayList<Meal>{
 | 
			
		||||
 | 
			
		||||
@ -95,9 +95,9 @@ class HomeFragment : Fragment() {
 | 
			
		||||
    private fun addCurrentTimeTable() {
 | 
			
		||||
        val dayIndex = NotRetardedCalendar().getDayOfWeekIndex()
 | 
			
		||||
 | 
			
		||||
        if (mainActivity.getCurrentTimeTableWeek().isNotEmpty() && dayIndex < 6) {
 | 
			
		||||
        if (mainActivity.getTimeTableCurrentWeek().isNotEmpty() && dayIndex < 6) {
 | 
			
		||||
 | 
			
		||||
            val timeTableDay = mainActivity.getCurrentTimeTableWeek()[dayIndex]
 | 
			
		||||
            val timeTableDay = mainActivity.getTimeTableCurrentWeek()[dayIndex]
 | 
			
		||||
 | 
			
		||||
            for (i in 0..5) {
 | 
			
		||||
                val lessonCardView = LessonCardView(context!!, null)
 | 
			
		||||
 | 
			
		||||
@ -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.getCurrentTimeTableWeek()[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
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
    <string name="app_name" translatable="false">Project Laogai</string>
 | 
			
		||||
    <string name="navigation_drawer_open">Open navigation drawer</string>
 | 
			
		||||
    <string name="navigation_drawer_close">Close navigation drawer</string>
 | 
			
		||||
    <string name="nav_header_title" translatable="false">hso App 0.2.1</string>
 | 
			
		||||
    <string name="nav_header_title" translatable="false">hso App 0.2.2</string>
 | 
			
		||||
    <string name="nav_header_subtitle" translatable="false">seil0@mosad.xyz</string>
 | 
			
		||||
    <string name="nav_header_desc" translatable="false">Project Laogai</string>
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@
 | 
			
		||||
    <string name="primary_color">primary color</string>
 | 
			
		||||
    <string name="main_color_desc">The primary color, default is indigo</string>
 | 
			
		||||
    <string name="select">select</string>
 | 
			
		||||
    <string name="version" translatable="false">version 0.2.1</string>
 | 
			
		||||
    <string name="version" translatable="false">version 0.2.2</string>
 | 
			
		||||
    <string name="about">about</string>
 | 
			
		||||
    <string name="about_txtView" translatable="false">hso App by @Seil0</string>
 | 
			
		||||
    <string name="about_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 seil0@mosad.xyz "</string>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user