added lesson as custom gui component

This commit is contained in:
2018-10-25 16:44:36 +02:00
parent 8741652638
commit a367865971
5 changed files with 93 additions and 90 deletions

View File

@ -20,13 +20,17 @@
*
*/
package org.mosad.seil0.projectlaogai
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.Color.*
import android.os.Build
import android.os.Bundle
import android.support.annotation.RequiresApi
import android.support.v4.app.Fragment
import android.support.v7.widget.CardView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -71,34 +75,43 @@ class HomeFragment : Fragment() {
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
}
@TargetApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.O)
@SuppressLint("SetTextI18n")
private fun addLessons() {
// for each lesson to display on homescreen create a cardview
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)
val cardView = CardView(context!!)
val linLayout = LinearLayout(context)
val tv = TextView(context)
lessonCardView1.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView1.getTxtViewTime().text = "8.00 - 9.30"
cardView.radius = 20F
cardView.cardElevation = 10F
cardView.setContentPadding(10,10,10,10)
cardView.preventCornerOverlap = true
cardView.useCompatPadding = true
lessonCardView2.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView2.getTxtViewTime().text = "8.00 - 9.30"
linLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 160)
linLayout.orientation = LinearLayout.HORIZONTAL
lessonCardView3.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView3.getTxtViewTime().text = "8.00 - 9.30"
lessonCardView4.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView4.getTxtViewTime().text = "8.00 - 9.30"
tv.text = "test\nRaum abc"
lessonCardView5.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
lessonCardView5.getTxtViewTime().text = "8.00 - 9.30"
linLayout.addView(tv)
cardView.addView(linLayout)
lessonCardView1.setBackgroundColor(Color.parseColor("#3F51B5"))
// ff00ddff
// TODO make lesson card an seperate oject
//var lessonCardView = LessonCardView(context!!, null)
linLayoutTimeTable.addView(cardView)
linLayoutTimeTable.run {
addView(lessonCardView1)
addView(lessonCardView2)
addView(lessonCardView3)
addView(lessonCardView4)
addView(lessonCardView5)
}
}
}