Visual changes, mostly colour-related

This commit is contained in:
denizk0461
2023-04-12 22:07:18 +02:00
parent d55a304cec
commit 53c2a2a9c4
13 changed files with 77 additions and 21 deletions
@@ -1,14 +1,15 @@
package com.denizk0461.studip.adapter
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
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(events: List<StudIPEvent>, private val currentDay: Int) : RecyclerView.Adapter<StudIPEventAdapter.EventViewHolder>() {
class StudIPEventAdapter(
events: List<StudIPEvent>, private val currentDay: Int, private val onClickListener: OnClickListener
) : RecyclerView.Adapter<StudIPEventAdapter.EventViewHolder>() {
private val filteredEvents: List<StudIPEvent> = events.filter { it.day == currentDay }
@@ -41,7 +42,20 @@ class StudIPEventAdapter(events: List<StudIPEvent>, private val currentDay: Int)
// holder.binding.cardBackground.cardForegroundColor = Color.TRANSPARENT
}
holder.binding.cardBackground.setOnClickListener {
onClickListener.onClick(currentItem)
}
holder.binding.cardBackground.setOnLongClickListener {
onClickListener.onLongClick(currentItem)
true
}
// TODO inflate view saying "no events!" or sth
}
interface OnClickListener {
fun onClick(event: StudIPEvent)
fun onLongClick(event: StudIPEvent)
}
}
@@ -7,7 +7,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.denizk0461.studip.model.StudIPEvent
import com.denizk0461.studip.databinding.ItemEventPageBinding
class StudIPEventPageAdapter(private var events: List<StudIPEvent>) : RecyclerView.Adapter<StudIPEventPageAdapter.EventPageViewHolder>() {
class StudIPEventPageAdapter(private var events: List<StudIPEvent>, private val onClickListener: StudIPEventAdapter.OnClickListener) : RecyclerView.Adapter<StudIPEventPageAdapter.EventPageViewHolder>() {
class EventPageViewHolder(val binding: ItemEventPageBinding) : RecyclerView.ViewHolder(binding.root)
@@ -25,7 +25,7 @@ class StudIPEventPageAdapter(private var events: List<StudIPEvent>) : RecyclerVi
holder.binding.pageRecyclerView.apply {
layoutManager = LinearLayoutManager(holder.binding.root.context, LinearLayoutManager.VERTICAL, false)
adapter = StudIPEventAdapter(events, currentDay = position) // TODO check if empty
adapter = StudIPEventAdapter(events, currentDay = position, onClickListener) // TODO check if empty
scheduleLayoutAnimation()
}
}
@@ -10,8 +10,10 @@ import androidx.fragment.app.viewModels
import androidx.navigation.fragment.NavHostFragment.Companion.findNavController
import com.denizk0461.studip.R
import com.denizk0461.studip.activity.FetcherActivity
import com.denizk0461.studip.adapter.StudIPEventAdapter
import com.denizk0461.studip.adapter.StudIPEventPageAdapter
import com.denizk0461.studip.databinding.FragmentEventBinding
import com.denizk0461.studip.model.StudIPEvent
import com.denizk0461.studip.viewmodel.EventViewModel
import com.google.android.material.tabs.TabLayoutMediator
import java.util.*
@@ -55,7 +57,14 @@ class EventFragment : Fragment() {
else -> 0
}
viewPagerAdapter = StudIPEventPageAdapter(listOf())//DummyData.events.toList())
viewPagerAdapter = StudIPEventPageAdapter(listOf(), object : StudIPEventAdapter.OnClickListener {
override fun onClick(event: StudIPEvent) {
// do nothing
}
override fun onLongClick(event: StudIPEvent) {
}
})//DummyData.events.toList())
binding.viewPager.adapter = viewPagerAdapter
TabLayoutMediator(binding.dayTabLayout, binding.viewPager) { tab, position ->