cleanup, mensa detail view and timetbale fragment

This commit is contained in:
2018-10-27 14:11:47 +02:00
parent c77e535817
commit 5fd9db182a
13 changed files with 145 additions and 28 deletions

View File

@ -32,6 +32,7 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import ord.mosad.seil0.projectlaogai.uicomponents.LessonCardView
/**
* The "home" controller class

View File

@ -1,52 +0,0 @@
/**
* 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
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.widget.TextView
class LessonCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
private var txtViewLesson: TextView
private var txtViewTime: TextView
init {
inflate(context, R.layout.lesson_cardview,this)
txtViewLesson = findViewById(R.id.txtView_Lesson)
txtViewTime = findViewById(R.id.txtView_Time)
// workaround to prevent a white border
this.setBackgroundColor(Color.parseColor("#3F51B5"))
}
fun getTxtViewLesson(): TextView {
return txtViewLesson
}
fun getTxtViewTime(): TextView {
return txtViewTime
}
}

View File

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

View File

@ -22,18 +22,19 @@
package org.mosad.seil0.projectlaogai
import android.graphics.drawable.GradientDrawable
import android.annotation.SuppressLint
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 android.widget.TextView
import ord.mosad.seil0.projectlaogai.uicomponents.MensaDayCardView
import ord.mosad.seil0.projectlaogai.uicomponents.MenuCardView
/**
* A simple [Fragment] subclass.
*
* The mensa controller class
* contains all needed parts to display and the mensa detail screen
*/
class MensaFragment : Fragment() {
@ -50,10 +51,10 @@ class MensaFragment : Fragment() {
return view
}
@SuppressLint("SetTextI18n")
fun addDay() {
val linLayoutDay = LinearLayout(context)
val txtViewDayHeading = TextView(context, null, R.string.sample_date)
val cardViewMensaDay = MensaDayCardView(context!!, null)
val menuViewMenu1 = MenuCardView(context!!, null)
val menuViewMenu2 = MenuCardView(context!!, null)
@ -62,13 +63,23 @@ class MensaFragment : Fragment() {
menuViewMenu2.getTxtViewMenuHeading().text = "Essen 2"
menuViewMenu2.getTxtViewMenu().text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
linLayoutDay.orientation = LinearLayout.VERTICAL
linLayoutDay.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
linLayoutDay.addView(txtViewDayHeading)
linLayoutDay.addView(menuViewMenu1)
linLayoutDay.addView(menuViewMenu2)
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu1)
cardViewMensaDay.getLinLayoutMensaDay().addView(menuViewMenu2)
linLayoutMensaFragment.addView(cardViewMensaDay)
linLayoutMensaFragment.addView(linLayoutDay)
val cardViewMensaDay2 = MensaDayCardView(context!!, null)
val menuViewMenu12 = MenuCardView(context!!, null)
val menuViewMenu22 = MenuCardView(context!!, null)
menuViewMenu12.getTxtViewMenuHeading().text = "Essen 12"
menuViewMenu12.getTxtViewMenu().text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
menuViewMenu22.getTxtViewMenuHeading().text = "Essen 22"
menuViewMenu22.getTxtViewMenu().text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
cardViewMensaDay2.getLinLayoutMensaDay().addView(menuViewMenu12)
cardViewMensaDay2.getLinLayoutMensaDay().addView(menuViewMenu22)
linLayoutMensaFragment.addView(cardViewMensaDay2)
}

View File

@ -1,30 +0,0 @@
package org.mosad.seil0.projectlaogai
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.widget.TextView
class MenuCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : androidx.cardview.widget.CardView(context, attrs){
private var txtViewMenuHeading: TextView
private var txtViewMenu: TextView
init {
inflate(context, R.layout.menu_cardview,this)
txtViewMenuHeading = findViewById(R.id.txtView_MenuHeading)
txtViewMenu = findViewById(R.id.txtView_Menu)
// workaround to prevent a white border
this.setBackgroundColor(Color.TRANSPARENT)
}
fun getTxtViewMenuHeading(): TextView {
return txtViewMenuHeading
}
fun getTxtViewMenu(): TextView {
return txtViewMenu
}
}

View File

@ -0,0 +1,25 @@
package org.mosad.seil0.projectlaogai
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
/**
* The timetable controller class
* contains all needed parts to display and the timetable detail screen
*/
class TimeTableFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_time_table, container, false)
return view
}
}