This repository has been archived on 2026-05-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
weserplaner/app/src/main/java/com/denizk0461/studip/fragment/FirstFragment.kt
T

53 lines
2.0 KiB
Kotlin
Raw Normal View History

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
import androidx.navigation.fragment.findNavController
2023-04-08 13:43:26 +02:00
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.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 13:43:26 +02:00
private lateinit var recyclerViewAdapter: StudIPEventAdapter
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 13:43:26 +02:00
recyclerViewAdapter = StudIPEventAdapter(DummyData.events.toList())
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
}
}