Archived
Added bottom navigation view (currently unpopulated) and changed logic for pages
This commit is contained in:
@@ -1,33 +1,46 @@
|
||||
package com.denizk0461.studip.adapter
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.denizk0461.studip.R
|
||||
import com.denizk0461.studip.model.StudIPEvent
|
||||
import com.denizk0461.studip.databinding.ItemEventBinding
|
||||
|
||||
class StudIPEventAdapter(private val events: List<StudIPEvent>) : RecyclerView.Adapter<StudIPEventAdapter.EventViewHolder>() {
|
||||
class StudIPEventAdapter(events: List<StudIPEvent>, private val currentDay: Int) : RecyclerView.Adapter<StudIPEventAdapter.EventViewHolder>() {
|
||||
|
||||
private val filteredEvents: List<StudIPEvent> = events.filter { it.day == currentDay }
|
||||
|
||||
class EventViewHolder(val binding: ItemEventBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EventViewHolder = EventViewHolder(
|
||||
ItemEventBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EventViewHolder {
|
||||
return EventViewHolder(
|
||||
ItemEventBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = events.size
|
||||
override fun getItemCount(): Int = filteredEvents.size
|
||||
|
||||
override fun onBindViewHolder(holder: EventViewHolder, position: Int) {
|
||||
val currentItem = events[position]
|
||||
val currentItem = filteredEvents[position]
|
||||
|
||||
holder.binding.textTitle.text = currentItem.title
|
||||
holder.binding.textLecturers.text = currentItem.lecturer
|
||||
holder.binding.textRoom.text = currentItem.room
|
||||
holder.binding.textTimeslot.text = currentItem.timeslot()
|
||||
|
||||
if (true) { // highlight
|
||||
// holder.binding.cardBackground.cardForegroundColor = holder.binding.root.context.getColorStateList(
|
||||
// R.color.list_card_selected)
|
||||
} else { // un-highlight
|
||||
// holder.binding.cardBackground.cardForegroundColor = Color.TRANSPARENT
|
||||
}
|
||||
|
||||
// TODO inflate view saying "no events!" or sth
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class StudIPEventPageAdapter(private val events: List<StudIPEvent>) : RecyclerVi
|
||||
|
||||
holder.binding.pageRecyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(holder.binding.root.context, LinearLayoutManager.VERTICAL, false)
|
||||
adapter = StudIPEventAdapter(events.filter { it.day == position }) // TODO check if empty
|
||||
adapter = StudIPEventAdapter(events, currentDay = position) // TODO check if empty
|
||||
scheduleLayoutAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ class EventFragment : Fragment() {
|
||||
binding.recyclerView.onFlingListener = null
|
||||
pagerSnapHelper.attachToRecyclerView(binding.recyclerView)
|
||||
// binding.recyclerView.scheduleLayoutAnimation()
|
||||
binding.recyclerView.scrollToPosition(dayOfWeek)
|
||||
binding.dayTabs.getTabAt(dayOfWeek)?.select()
|
||||
|
||||
switchToCurrentDayView()
|
||||
}
|
||||
|
||||
binding.fab.setOnClickListener { view ->
|
||||
@@ -107,12 +107,29 @@ class EventFragment : Fragment() {
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
switchToCurrentDayView()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
private fun switchToCurrentDayView() {
|
||||
binding.recyclerView.scrollToPosition(dayOfWeek)
|
||||
binding.dayTabs.getTabAt(dayOfWeek)?.select()
|
||||
}
|
||||
|
||||
private fun launchWebview() {
|
||||
findNavController(this).navigate(R.id.action_FirstFragment_to_SecondFragment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlights the current or next course.
|
||||
*/
|
||||
private fun highlightCurrentCourse() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"
|
||||
android:color="@color/primaryLight" />
|
||||
<item android:state_pressed="true"
|
||||
android:state_enabled="false"
|
||||
android:color="@android:color/transparent" />
|
||||
<item android:state_enabled="false"
|
||||
android:color="@android:color/transparent" />
|
||||
</selector>
|
||||
@@ -7,6 +7,14 @@
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".activity.MainActivity">
|
||||
|
||||
<include layout="@layout/content_main" />
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="bottom" />
|
||||
|
||||
<include layout="@layout/content_main"
|
||||
android:layout_marginBottom="56dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -11,51 +11,53 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
<!-- <com.google.android.material.appbar.MaterialToolbar-->
|
||||
<!-- android:id="@+id/toolbar"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="?attr/actionBarSize"/>-->
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="48dp"
|
||||
android:text="@string/your_schedule"
|
||||
android:textSize="32sp"
|
||||
android:fontFamily="@font/lato_bolditalic"
|
||||
android:layout_marginHorizontal="16dp"/>
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:title="title"/>
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/day_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabMode="scrollable"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/day_tabs"
|
||||
android:layout_width="match_parent"
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabMode="scrollable"
|
||||
android:layout_gravity="bottom">
|
||||
android:text="@string/monday"/>
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/monday"/>
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/tuesday"/>
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/tuesday"/>
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/wednesday"/>
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/wednesday"/>
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/thursday"/>
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/thursday"/>
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/friday"/>
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/friday"/>
|
||||
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/card_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.Material3.CardView.Outlined">
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.StudIPTimetable" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
|
||||
<!-- colour -->
|
||||
<item name="colorPrimary">@color/primaryDark</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -2,4 +2,7 @@
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
|
||||
<color name="primaryLight">#0F4759</color>
|
||||
<color name="primaryDark">#62CCE4</color>
|
||||
</resources>
|
||||
@@ -13,6 +13,8 @@
|
||||
<string name="thursday">THURSDAY</string>
|
||||
<string name="friday">FRIDAY</string>
|
||||
|
||||
<string name="your_schedule">Your Schedule</string>
|
||||
|
||||
<string name="lorem_ipsum">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in scelerisque sem. Mauris
|
||||
volutpat, dolor id interdum ullamcorper, risus dolor egestas lectus, sit amet mattis purus
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.StudIPTimetable" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
|
||||
<!-- customisation -->
|
||||
<item name="fontFamily">@font/lato_regular</item>
|
||||
|
||||
<!-- colour -->
|
||||
<item name="colorPrimary">@color/primaryLight</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.StudIPTimetable" parent="Base.Theme.StudIPTimetable" />
|
||||
|
||||
Reference in New Issue
Block a user