2018-10-24 18:22:05 +02:00
/ * *
* 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
2018-10-25 16:44:36 +02:00
import android.annotation.TargetApi
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.Color.*
import android.os.Build
2018-10-24 18:22:05 +02:00
import android.os.Bundle
2018-10-25 16:44:36 +02:00
import android.support.annotation.RequiresApi
2018-10-24 18:22:05 +02:00
import android.support.v4.app.Fragment
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 \n Couscous \n Blattsalat "
txtViewMenu2 . text = " Riesen Currywurst \n Curryketchup \n Gitterkartoffeln \n Blattsalat "
}
2018-10-25 16:44:36 +02:00
@TargetApi ( Build . VERSION_CODES . O )
@RequiresApi ( Build . VERSION_CODES . O )
2018-10-24 18:22:05 +02:00
@SuppressLint ( " SetTextI18n " )
private fun addLessons ( ) {
// for each lesson to display on homescreen create a cardview
2018-10-25 16:44:36 +02:00
val lessonCardView1 = LessonCardView ( context !! , null )
val lessonCardView2 = LessonCardView ( context !! , null )
val lessonCardView3 = LessonCardView ( context !! , null )
val lessonCardView4 = LessonCardView ( context !! , null )
val lessonCardView5 = LessonCardView ( context !! , null )
2018-10-24 18:22:05 +02:00
2018-10-25 16:44:36 +02:00
lessonCardView1 . getTxtViewLesson ( ) . text = " Computernetze 1 \n Mayer E. \n A213 "
lessonCardView1 . getTxtViewTime ( ) . text = " 8.00 - 9.30 "
2018-10-24 18:22:05 +02:00
2018-10-25 16:44:36 +02:00
lessonCardView2 . getTxtViewLesson ( ) . text = " Computernetze 1 \n Mayer E. \n A213 "
lessonCardView2 . getTxtViewTime ( ) . text = " 8.00 - 9.30 "
2018-10-24 18:22:05 +02:00
2018-10-25 16:44:36 +02:00
lessonCardView3 . getTxtViewLesson ( ) . text = " Computernetze 1 \n Mayer E. \n A213 "
lessonCardView3 . getTxtViewTime ( ) . text = " 8.00 - 9.30 "
2018-10-24 18:22:05 +02:00
2018-10-25 16:44:36 +02:00
lessonCardView4 . getTxtViewLesson ( ) . text = " Computernetze 1 \n Mayer E. \n A213 "
lessonCardView4 . getTxtViewTime ( ) . text = " 8.00 - 9.30 "
2018-10-24 18:22:05 +02:00
2018-10-25 16:44:36 +02:00
lessonCardView5 . getTxtViewLesson ( ) . text = " Computernetze 1 \n Mayer E. \n A213 "
lessonCardView5 . getTxtViewTime ( ) . text = " 8.00 - 9.30 "
2018-10-24 18:22:05 +02:00
2018-10-25 16:44:36 +02:00
lessonCardView1 . setBackgroundColor ( Color . parseColor ( " #3F51B5 " ) )
// ff00ddff
2018-10-24 18:22:05 +02:00
2018-10-25 16:44:36 +02:00
linLayoutTimeTable . run {
addView ( lessonCardView1 )
addView ( lessonCardView2 )
addView ( lessonCardView3 )
addView ( lessonCardView4 )
addView ( lessonCardView5 )
}
2018-10-24 18:22:05 +02:00
}
}