added lesson as custom gui component
This commit is contained in:
parent
8741652638
commit
a367865971
|
@ -20,13 +20,17 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.mosad.seil0.projectlaogai
|
package org.mosad.seil0.projectlaogai
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
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.os.Bundle
|
||||||
|
import android.support.annotation.RequiresApi
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
import android.support.v7.widget.CardView
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -71,34 +75,43 @@ class HomeFragment : Fragment() {
|
||||||
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
|
txtViewMenu2.text = "Riesen Currywurst\nCurryketchup\nGitterkartoffeln\nBlattsalat"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.O)
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private fun addLessons() {
|
private fun addLessons() {
|
||||||
|
|
||||||
// for each lesson to display on homescreen create a cardview
|
// 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!!)
|
lessonCardView1.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
|
||||||
val linLayout = LinearLayout(context)
|
lessonCardView1.getTxtViewTime().text = "8.00 - 9.30"
|
||||||
val tv = TextView(context)
|
|
||||||
|
|
||||||
cardView.radius = 20F
|
lessonCardView2.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
|
||||||
cardView.cardElevation = 10F
|
lessonCardView2.getTxtViewTime().text = "8.00 - 9.30"
|
||||||
cardView.setContentPadding(10,10,10,10)
|
|
||||||
cardView.preventCornerOverlap = true
|
|
||||||
cardView.useCompatPadding = true
|
|
||||||
|
|
||||||
linLayout.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 160)
|
lessonCardView3.getTxtViewLesson().text = "Computernetze 1\nMayer E.\nA213"
|
||||||
linLayout.orientation = LinearLayout.HORIZONTAL
|
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)
|
lessonCardView1.setBackgroundColor(Color.parseColor("#3F51B5"))
|
||||||
cardView.addView(linLayout)
|
// ff00ddff
|
||||||
|
|
||||||
// TODO make lesson card an seperate oject
|
linLayoutTimeTable.run {
|
||||||
//var lessonCardView = LessonCardView(context!!, null)
|
addView(lessonCardView1)
|
||||||
|
addView(lessonCardView2)
|
||||||
linLayoutTimeTable.addView(cardView)
|
addView(lessonCardView3)
|
||||||
|
addView(lessonCardView4)
|
||||||
|
addView(lessonCardView5)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,53 @@
|
||||||
|
/**
|
||||||
|
* 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
|
package org.mosad.seil0.projectlaogai
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.Color
|
||||||
import android.support.v7.widget.CardView
|
import android.support.v7.widget.CardView
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.widget.TextView
|
||||||
import kotlinx.android.synthetic.main.lesson_cardview.view.*
|
|
||||||
|
class LessonCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : CardView(context, attrs){
|
||||||
|
|
||||||
|
private var txtViewLesson: TextView
|
||||||
|
private var txtViewTime: TextView
|
||||||
|
|
||||||
class LessonCardView @JvmOverloads constructor(
|
|
||||||
context: Context,
|
|
||||||
attrs: AttributeSet? = null
|
|
||||||
) : CardView(context, attrs){
|
|
||||||
init {
|
init {
|
||||||
LayoutInflater.from(context).inflate(R.layout.lesson_cardview,this, false)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -36,6 +36,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
app:srcCompat="@android:drawable/ic_dialog_email"/>
|
app:srcCompat="@android:drawable/ic_dialog_email" android:visibility="invisible"/>
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
|
@ -14,9 +14,9 @@
|
||||||
android:id="@+id/cardView"
|
android:id="@+id/cardView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="125dp"
|
android:layout_height="125dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="5dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="5dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:maxHeight="125dp"
|
android:maxHeight="125dp"
|
||||||
app:cardCornerRadius="15dp"
|
app:cardCornerRadius="15dp"
|
||||||
|
@ -52,8 +52,8 @@
|
||||||
android:id="@+id/cardView2"
|
android:id="@+id/cardView2"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="125dp"
|
android:layout_height="125dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="5dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="5dp"
|
||||||
app:cardCornerRadius="15dp"
|
app:cardCornerRadius="15dp"
|
||||||
app:cardUseCompatPadding="true"
|
app:cardUseCompatPadding="true"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -86,66 +86,23 @@
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="5dp"
|
||||||
android:background="@color/colorPrimary"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/cardView2" android:id="@+id/scrollView_TimeTable">
|
app:layout_constraintTop_toBottomOf="@+id/cardView2" android:id="@+id/scrollView_TimeTable"
|
||||||
|
>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linLayout_TimeTable"
|
android:id="@+id/linLayout_TimeTable"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/cardView2">
|
app:layout_constraintTop_toBottomOf="@+id/cardView2">
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="80dp"
|
|
||||||
app:cardBackgroundColor="@android:color/holo_red_light"
|
|
||||||
app:cardCornerRadius="10dp"
|
|
||||||
app:cardElevation="5dp"
|
|
||||||
app:cardPreventCornerOverlap="true"
|
|
||||||
app:cardUseCompatPadding="true"
|
|
||||||
app:contentPadding="5dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView5"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/a_lesson"
|
|
||||||
android:textColor="@android:color/primary_text_light"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:typeface="sans"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView6"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="end"
|
|
||||||
android:text="@string/a_time"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/lesson_cardview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,19 @@
|
||||||
<android.support.v7.widget.CardView
|
<android.support.v7.widget.CardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp"
|
android:layout_height="wrap_content"
|
||||||
app:cardBackgroundColor="@android:color/holo_blue_bright"
|
app:cardBackgroundColor="@android:color/holo_blue_bright"
|
||||||
app:cardCornerRadius="10dp"
|
app:contentPadding="5dp" app:cardElevation="5dp"
|
||||||
app:cardElevation="5dp"
|
app:cardUseCompatPadding="true" app:cardPreventCornerOverlap="false">
|
||||||
app:cardPreventCornerOverlap="true"
|
|
||||||
app:cardUseCompatPadding="true"
|
|
||||||
app:contentPadding="5dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView4"
|
android:id="@+id/txtView_Lesson"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/a_lesson"
|
android:text="@string/a_lesson"
|
||||||
|
@ -27,7 +24,7 @@
|
||||||
android:typeface="sans"/>
|
android:typeface="sans"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/txtView_Time"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
|
|
Loading…
Reference in New Issue