Browse Source

added the timetable week vie

pull/20/head
Jannik 4 years ago
parent
commit
9c5eeaa20b
  1. 1
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  2. 85
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  3. 16
      app/src/main/res/layout/fragment_time_table.xml

1
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

@ -117,6 +117,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
R.id.nav_timetable -> {
val timeTableFragment = TimeTableFragment()
timeTableFragment.setMainActivity(this)
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.fragment_container, timeTableFragment)
fragmentTransaction.commit()

85
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -1,12 +1,42 @@
package org.mosad.seil0.projectlaogai.fragments
/**
* ProjectLaogai
*
* Copyright 2018 <seil0@mosad.xyz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package org.mosad.seil0.projectlaogai.fragments
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import org.mosad.seil0.projectlaogai.MainActivity
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
import org.mosad.seil0.projectlaogai.uicomponents.LessonCardView
import org.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
import java.util.*
/**
* The timetable controller class
@ -14,13 +44,66 @@ import org.mosad.seil0.projectlaogai.R
*/
class TimeTableFragment : Fragment() {
private lateinit var linLayoutTTFragment: LinearLayout
private var mainActivity = MainActivity()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_time_table, container, false)
linLayoutTTFragment = view.findViewById(R.id.linLayout_TTFragment)
addCurrentWeek()
return view
}
private fun addCurrentWeek() {
doAsync {
uiThread {
for(day in Calendar.getInstance().get(Calendar.DAY_OF_WEEK)..7) {
println("Day index: " + (day - 2))
val cardViewTimeTableDay = MensaDayCardView(context!!, null)
cardViewTimeTableDay.setDayHeading((day - 1).toString())
// for each lessen of the day
for((i, lesson) in mainActivity.getCurrentTimeTableWeek()[day - 2].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)
}
linLayoutTTFragment.addView(cardViewTimeTableDay)
}
// 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)
//}
}
}
}
fun setMainActivity(mainActivity: MainActivity) {
this.mainActivity = mainActivity
}
}

16
app/src/main/res/layout/fragment_time_table.xml

@ -5,9 +5,19 @@
android:layout_height="match_parent"
tools:context=".fragments.TimeTableFragment">
<TextView
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment"/>
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/linLayout_TTFragment">
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close