boutta make a big change

This commit is contained in:
denizk0461
2023-04-08 15:13:11 +02:00
parent 9c0e67b396
commit 76370d78a8
17 changed files with 92 additions and 23 deletions
@@ -30,6 +30,7 @@ class StudIPEventAdapter(private val events: List<StudIPEvent>) : RecyclerView.A
holder.binding.root,
false
).also { item ->
Log.d("HELLO", "generating ${event.title}...2")
itemCount += 1
item.textTitle.text = event.title
item.textLecturers.text = event.lecturer.joinToString(", ")
@@ -0,0 +1,46 @@
package com.denizk0461.studip.adapter
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.denizk0461.studip.data.StudIPEvent
import com.denizk0461.studip.databinding.ItemEventBinding
import com.denizk0461.studip.databinding.ItemEventPageBinding
class StudIPEventPageAdapter(private val events: List<StudIPEvent>) : RecyclerView.Adapter<StudIPEventPageAdapter.EventPageViewHolder>() {
class EventPageViewHolder(val binding: ItemEventPageBinding) : RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EventPageViewHolder = EventPageViewHolder(
ItemEventPageBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
)
override fun getItemCount(): Int = 5
override fun onBindViewHolder(holder: EventPageViewHolder, position: Int) {
var itemCount = 0
events.filter { it.day == position }.forEach { event ->
val newView = ItemEventBinding.inflate(
LayoutInflater.from(holder.binding.root.context),
holder.binding.root,
false
).also { item ->
Log.d("HELLO", "generating ${event.title}...2")
itemCount += 1
item.textTitle.text = event.title
item.textLecturers.text = event.lecturer.joinToString(", ")
item.textRoom.text = event.room
item.textTimeslot.text = event.timeslot
}
holder.binding.pageLayout.addView(newView.root)
}
if (itemCount == 0) {
// TODO inflate view saying "no events!" or sth
}
}
}
@@ -9,5 +9,6 @@ object DummyData {
StudIPEvent("Key Moments", arrayOf("Esders-Angermund"), "GW2 B2890", 2, 2, 1),
StudIPEvent("ULS-1", arrayOf("Herrmann"), "GW2 B2890", 2, 3, 1),
StudIPEvent("Gesellschaft und Raum", arrayOf("Lossau", "Mossig"), "GW2 B1820", 3, 1, 1),
StudIPEvent("Gesellschaft und Raum2", arrayOf("Lossau", "Mossig"), "GW2 B1820", 4, 4, 2),
)
}
@@ -13,7 +13,7 @@ data class StudIPEvent(
private val timeSlotEndTimes: List<String> = listOf("09:45", "11:45", "13:45", "15:45", "17:45", "19:45")
val timeslot: String =
"${timeSlotStartTimes[timeslotStart]} ${timeSlotEndTimes[timeslots - 1]}"
"${timeSlotStartTimes[timeslotStart]} ${timeSlotEndTimes[timeslotStart + timeslots - 1]}"
override fun equals(other: Any?): Boolean {
if (this === other) return true
@@ -5,12 +5,9 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.PagerSnapHelper
import com.denizk0461.studip.adapter.StudIPEventAdapter
import com.denizk0461.studip.adapter.StudIPEventPageAdapter
import com.denizk0461.studip.data.DummyData
import com.denizk0461.studip.databinding.FragmentFirstBinding
@@ -24,7 +21,7 @@ class FirstFragment : Fragment() {
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
private lateinit var recyclerViewAdapter: StudIPEventAdapter
private lateinit var recyclerViewAdapter: StudIPEventPageAdapter
private lateinit var recyclerViewLayoutManager: LinearLayoutManager
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@@ -35,7 +32,7 @@ class FirstFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
recyclerViewAdapter = StudIPEventAdapter(DummyData.events.toList())
recyclerViewAdapter = StudIPEventPageAdapter(DummyData.events.toList())
binding.recyclerView.adapter = recyclerViewAdapter
recyclerViewLayoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
binding.recyclerView.layoutManager = recyclerViewLayoutManager
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+39 -16
View File
@@ -2,26 +2,49 @@
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="8dp"
android:paddingVertical="4dp"
android:orientation="vertical">
<TextView
android:id="@+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.Material3.CardView.Outlined">
<TextView
android:id="@+id/text_room"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/text_lecturers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:fontFamily="@font/lato_bolditalic"/>
<TextView
android:id="@+id/text_timeslot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="4dp"/>
<TextView
android:id="@+id/text_lecturers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text_timeslot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text_room"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.google.android.material.card.MaterialCardView>
</androidx.appcompat.widget.LinearLayoutCompat>
+1
View File
@@ -3,6 +3,7 @@
<style name="Base.Theme.StudIPTimetable" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
<item name="fontFamily">@font/lato_regular</item>
</style>
<style name="Theme.StudIPTimetable" parent="Base.Theme.StudIPTimetable" />