Archived
Added ExamOverviewFragment.kt and RoomFinderFragment.kt as well as respective layouts and view models to implement later; minor reformatting
This commit is contained in:
@@ -2,17 +2,27 @@ package com.denizk0461.weserplaner.fragment
|
||||
|
||||
import android.content.Context
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.denizk0461.weserplaner.sheet.AppSheet
|
||||
|
||||
/**
|
||||
* Fragment super class providing common functionality. Fragments are used for providing the user
|
||||
* with different views and functionality. All fragments should inherit from this.
|
||||
*/
|
||||
open class AppFragment : Fragment() {
|
||||
abstract class AppFragment<T : ViewBinding> : Fragment() {
|
||||
|
||||
// Internal context object
|
||||
private lateinit var _context: Context
|
||||
|
||||
// Nullable view binding reference. Instantiate this in classes that extend this class.
|
||||
protected var _binding: T? = null
|
||||
|
||||
/*
|
||||
* Non-null reference to the view binding. This property is only valid between onCreateView and
|
||||
* onDestroyView.
|
||||
*/
|
||||
protected val binding: T get() = _binding!!
|
||||
|
||||
/**
|
||||
* Get non-null context. Only valid after onAttach().
|
||||
*/
|
||||
|
||||
@@ -25,16 +25,7 @@ import com.google.android.material.tabs.TabLayoutMediator
|
||||
* User-facing fragment view that displays the canteen offers from the website of the
|
||||
* Studierendenwerk Bremen.
|
||||
*/
|
||||
class CanteenFragment : AppFragment() {
|
||||
|
||||
// Nullable view binding reference
|
||||
private var _binding: FragmentCanteenBinding? = null
|
||||
|
||||
/*
|
||||
* Non-null reference to the view binding. This property is only valid between onCreateView and
|
||||
* onDestroyView.
|
||||
*/
|
||||
private val binding get() = _binding!!
|
||||
class CanteenFragment : AppFragment<FragmentCanteenBinding>() {
|
||||
|
||||
// Adapter for the view pager displaying all offers
|
||||
private lateinit var viewPagerAdapter: CanteenOfferPageAdapter
|
||||
|
||||
@@ -21,16 +21,7 @@ import com.denizk0461.weserplaner.viewmodel.CanteenPageViewModel
|
||||
* Fragment that is instantiated by [StudIPEventPageAdapter] to display individual days' pages and
|
||||
* their events.
|
||||
*/
|
||||
class CanteenPageFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
|
||||
|
||||
// Nullable view binding reference
|
||||
private var _binding: RecyclerViewBinding? = null
|
||||
|
||||
/*
|
||||
* Non-null reference to the view binding. This property is only valid between onCreateView and
|
||||
* onDestroyView.
|
||||
*/
|
||||
private val binding get() = _binding!!
|
||||
class CanteenPageFragment : AppFragment<RecyclerViewBinding>(), CanteenOfferItemAdapter.OnClickListener {
|
||||
|
||||
// View model reference for providing access to the database
|
||||
private val viewModel: CanteenPageViewModel by viewModels()
|
||||
|
||||
@@ -20,16 +20,7 @@ import java.util.*
|
||||
/**
|
||||
* User-facing fragment view that displays the user's Stud.IP schedule.
|
||||
*/
|
||||
class EventFragment : AppFragment() {
|
||||
|
||||
// Nullable view binding reference
|
||||
private var _binding: FragmentEventBinding? = null
|
||||
|
||||
/*
|
||||
* Non-null reference to the view binding. This property is only valid between onCreateView and
|
||||
* onDestroyView.
|
||||
*/
|
||||
private val binding get() = _binding!!
|
||||
class EventFragment : AppFragment<FragmentEventBinding>() {
|
||||
|
||||
// Adapter for the view pager displaying all events
|
||||
private lateinit var viewPagerAdapter: StudIPEventPageAdapter
|
||||
|
||||
@@ -18,16 +18,7 @@ import com.denizk0461.weserplaner.viewmodel.EventPageViewModel
|
||||
* Fragment that is instantiated by [StudIPEventPageAdapter] to display individual days' pages and
|
||||
* their events.
|
||||
*/
|
||||
class EventPageFragment : AppFragment(), StudIPEventItemAdapter.OnClickListener {
|
||||
|
||||
// Nullable view binding reference
|
||||
private var _binding: RecyclerViewBinding? = null
|
||||
|
||||
/*
|
||||
* Non-null reference to the view binding. This property is only valid between onCreateView and
|
||||
* onDestroyView.
|
||||
*/
|
||||
private val binding get() = _binding!!
|
||||
class EventPageFragment : AppFragment<RecyclerViewBinding>(), StudIPEventItemAdapter.OnClickListener {
|
||||
|
||||
// View model reference for providing access to the database
|
||||
private val viewModel: EventPageViewModel by viewModels()
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.denizk0461.weserplaner.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.denizk0461.weserplaner.databinding.FragmentExamOverviewBinding
|
||||
import com.denizk0461.weserplaner.viewmodel.ExamOverviewViewModel
|
||||
|
||||
/**
|
||||
* Fragment that shows the user an overview of their exams.
|
||||
*/
|
||||
class ExamOverviewFragment : AppFragment<FragmentExamOverviewBinding>() {
|
||||
|
||||
// View model reference for providing access to the database
|
||||
private val viewModel: ExamOverviewViewModel by viewModels()
|
||||
|
||||
// Instantiate the view binding
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
_binding = FragmentExamOverviewBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.denizk0461.weserplaner.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.denizk0461.weserplaner.databinding.FragmentRoomFinderBinding
|
||||
import com.denizk0461.weserplaner.viewmodel.RoomFinderViewModel
|
||||
|
||||
/**
|
||||
* Fragment view that the user can use to find specific rooms on the university campus.
|
||||
*/
|
||||
class RoomFinderFragment : AppFragment<FragmentRoomFinderBinding>() {
|
||||
|
||||
// View model reference for providing access to the database
|
||||
private val viewModel: RoomFinderViewModel by viewModels()
|
||||
|
||||
// Instantiate the view binding
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
_binding = FragmentRoomFinderBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
@@ -29,16 +29,7 @@ import java.util.*
|
||||
/**
|
||||
* User-facing fragment view that is used to change app settings.
|
||||
*/
|
||||
class SettingsFragment : AppFragment() {
|
||||
|
||||
// Nullable view binding reference
|
||||
private var _binding: FragmentSettingsBinding? = null
|
||||
|
||||
/*
|
||||
* Non-null reference to the view binding. This property is only valid between onCreateView and
|
||||
* onDestroyView.
|
||||
*/
|
||||
private val binding get() = _binding!!
|
||||
class SettingsFragment : AppFragment<FragmentSettingsBinding>() {
|
||||
|
||||
// View model reference for providing access to the database
|
||||
private val viewModel: SettingsViewModel by viewModels()
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.denizk0461.weserplaner.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
|
||||
/**
|
||||
* View model class for [com.denizk0461.weserplaner.fragment.ExamOverviewFragment].
|
||||
*/
|
||||
class ExamOverviewViewModel(application: Application) : AppViewModel(application) {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.denizk0461.weserplaner.viewmodel
|
||||
|
||||
import android.app.Application
|
||||
|
||||
/**
|
||||
* View model class for [com.denizk0461.weserplaner.fragment.RoomFinderFragment].
|
||||
*/
|
||||
class RoomFinderViewModel(application: Application) : AppViewModel(application) {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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"
|
||||
|
||||
@@ -19,16 +19,12 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/SheetCloseButton"
|
||||
android:id="@+id/button_cancel"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:minWidth="0dp"
|
||||
app:icon="@drawable/cross"
|
||||
app:iconPadding="0dp"
|
||||
app:iconTint="?attr/colorOnSurfaceVariant"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
@@ -18,16 +18,12 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/SheetCloseButton"
|
||||
android:id="@+id/button_cancel"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:minWidth="0dp"
|
||||
app:icon="@drawable/cross"
|
||||
app:iconPadding="0dp"
|
||||
app:iconTint="?attr/colorOnSurfaceVariant"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
@@ -19,16 +19,12 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/SheetCloseButton"
|
||||
android:id="@+id/button_cancel"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:minWidth="0dp"
|
||||
app:icon="@drawable/cross"
|
||||
app:iconPadding="0dp"
|
||||
app:iconTint="?attr/colorOnSurfaceVariant"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
@@ -18,18 +18,14 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/SheetCloseButton"
|
||||
android:id="@+id/button_cancel"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:minWidth="0dp"
|
||||
app:icon="@drawable/cross"
|
||||
app:iconPadding="0dp"
|
||||
app:iconTint="?attr/colorOnSurfaceVariant"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
@@ -102,4 +102,11 @@
|
||||
<style name="TimePickerButtonStyle" parent="Widget.MaterialComponents.Button.TextButton">
|
||||
<item name="android:textColor">@color/md_theme_light_primary</item>
|
||||
</style>
|
||||
|
||||
<style name="SheetCloseButton" parent="Widget.Material3.Button.IconButton.Filled.Tonal">
|
||||
<item name="icon">@drawable/cross</item>
|
||||
<item name="iconPadding">0dp</item>
|
||||
<item name="iconTint">?attr/colorOnSurfaceVariant</item>
|
||||
<item name="minWidth">0dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user