ProjectLaogai/app/src/main/java/org/mosad/seil0/projectlaogai/HomeFragment.kt

105 rindas
3.2 KiB
Kotlin

/**
* 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.annotation.SuppressLint
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.CardView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
/**
* The "home" controller class
* contains all needed parts to display the apps home screen
*/
class HomeFragment : Fragment() {
private lateinit var txtViewMenu1: TextView
private lateinit var txtViewMenu2: TextView
private lateinit var scrollViewTimeTable: ScrollView
private lateinit var linLayoutTimeTable: LinearLayout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_home, container, false)
// init UI elements
txtViewMenu1 = view.findViewById(R.id.txtView_Menu1)
txtViewMenu2 = view.findViewById(R.id.txtView_Menu2)
scrollViewTimeTable = view.findViewById(R.id.scrollView_TimeTable)
linLayoutTimeTable = view.findViewById(R.id.linLayout_TimeTable)
setText()
addLessons()
// Inflate the layout for this fragment
return view
}
@SuppressLint("SetTextI18n")
private fun setText() {
txtViewMenu1.text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
}
@SuppressLint("SetTextI18n")
private fun addLessons() {
// for each lesson to display on homescreen create a cardview
val cardView = CardView(context!!)
val linLayout = LinearLayout(context)
val tv = TextView(context)
cardView.radius = 20F
cardView.cardElevation = 10F
cardView.setContentPadding(10,10,10,10)
cardView.preventCornerOverlap = true
cardView.useCompatPadding = true
linLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 160)
linLayout.orientation = LinearLayout.HORIZONTAL
tv.text = "test\nRaum abc"
linLayout.addView(tv)
cardView.addView(linLayout)
// TODO make lesson card an seperate oject
//var lessonCardView = LessonCardView(context!!, null)
linLayoutTimeTable.addView(cardView)
}
}