2023-04-08 11:41:02 +02:00
|
|
|
package com.denizk0461.studip.fragment
|
|
|
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.view.ViewGroup
|
2023-04-08 13:43:26 +02:00
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
|
import androidx.recyclerview.widget.PagerSnapHelper
|
2023-04-08 15:13:11 +02:00
|
|
|
import com.denizk0461.studip.adapter.StudIPEventPageAdapter
|
2023-04-08 13:43:26 +02:00
|
|
|
import com.denizk0461.studip.data.DummyData
|
2023-04-08 11:41:02 +02:00
|
|
|
import com.denizk0461.studip.databinding.FragmentFirstBinding
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A simple [Fragment] subclass as the default destination in the navigation.
|
|
|
|
|
*/
|
|
|
|
|
class FirstFragment : Fragment() {
|
|
|
|
|
|
|
|
|
|
private var _binding: FragmentFirstBinding? = null
|
|
|
|
|
|
|
|
|
|
// This property is only valid between onCreateView and
|
|
|
|
|
// onDestroyView.
|
|
|
|
|
private val binding get() = _binding!!
|
2023-04-08 15:13:11 +02:00
|
|
|
private lateinit var recyclerViewAdapter: StudIPEventPageAdapter
|
2023-04-08 13:43:26 +02:00
|
|
|
private lateinit var recyclerViewLayoutManager: LinearLayoutManager
|
2023-04-08 11:41:02 +02:00
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
|
|
|
_binding = FragmentFirstBinding.inflate(inflater, container, false)
|
|
|
|
|
return binding.root
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
2023-04-08 15:13:11 +02:00
|
|
|
recyclerViewAdapter = StudIPEventPageAdapter(DummyData.events.toList())
|
2023-04-08 13:43:26 +02:00
|
|
|
binding.recyclerView.adapter = recyclerViewAdapter
|
|
|
|
|
recyclerViewLayoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
|
|
|
|
binding.recyclerView.layoutManager = recyclerViewLayoutManager
|
|
|
|
|
PagerSnapHelper().attachToRecyclerView(binding.recyclerView)
|
|
|
|
|
|
2023-04-08 11:41:02 +02:00
|
|
|
// binding.buttonFirst.setOnClickListener {
|
|
|
|
|
// findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment)
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
|
|
super.onDestroyView()
|
|
|
|
|
_binding = null
|
|
|
|
|
}
|
|
|
|
|
}
|