This is the home of the new hsoApp!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.2KB

  1. /**
  2. * ProjectLaogai
  3. *
  4. * Copyright 2018 <seil0@mosad.xyz>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19. * MA 02110-1301, USA.
  20. *
  21. */
  22. package org.mosad.seil0.projectlaogai
  23. import android.annotation.SuppressLint
  24. import android.os.Bundle
  25. import android.support.v4.app.Fragment
  26. import android.support.v7.widget.CardView
  27. import android.view.LayoutInflater
  28. import android.view.View
  29. import android.view.ViewGroup
  30. import android.widget.LinearLayout
  31. import android.widget.ScrollView
  32. import android.widget.TextView
  33. /**
  34. * The "home" controller class
  35. * contains all needed parts to display the apps home screen
  36. */
  37. class HomeFragment : Fragment() {
  38. private lateinit var txtViewMenu1: TextView
  39. private lateinit var txtViewMenu2: TextView
  40. private lateinit var scrollViewTimeTable: ScrollView
  41. private lateinit var linLayoutTimeTable: LinearLayout
  42. override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
  43. val view: View = inflater.inflate(R.layout.fragment_home, container, false)
  44. // init UI elements
  45. txtViewMenu1 = view.findViewById(R.id.txtView_Menu1)
  46. txtViewMenu2 = view.findViewById(R.id.txtView_Menu2)
  47. scrollViewTimeTable = view.findViewById(R.id.scrollView_TimeTable)
  48. linLayoutTimeTable = view.findViewById(R.id.linLayout_TimeTable)
  49. setText()
  50. addLessons()
  51. // Inflate the layout for this fragment
  52. return view
  53. }
  54. @SuppressLint("SetTextI18n")
  55. private fun setText() {
  56. txtViewMenu1.text = "Buntes Pfannengemüse\nCouscous\nBlattsalat"
  57. txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
  58. }
  59. @SuppressLint("SetTextI18n")
  60. private fun addLessons() {
  61. // for each lesson to display on homescreen create a cardview
  62. val cardView = CardView(context!!)
  63. val linLayout = LinearLayout(context)
  64. val tv = TextView(context)
  65. cardView.radius = 20F
  66. cardView.cardElevation = 10F
  67. cardView.setContentPadding(10,10,10,10)
  68. cardView.preventCornerOverlap = true
  69. cardView.useCompatPadding = true
  70. linLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 160)
  71. linLayout.orientation = LinearLayout.HORIZONTAL
  72. tv.text = "test\nRaum abc"
  73. linLayout.addView(tv)
  74. cardView.addView(linLayout)
  75. // TODO make lesson card an seperate oject
  76. //var lessonCardView = LessonCardView(context!!, null)
  77. linLayoutTimeTable.addView(cardView)
  78. }
  79. }