Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
moved cafeteria in shared fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasjungmann committed Feb 2, 2023
1 parent 3172d20 commit 9690be4
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 90 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,4 @@ protobuf {
}

apply plugin: 'com.google.gms.google-services'

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import de.tum.`in`.tumcampusapp.component.tumui.lectures.fragment.LecturesFragme
import de.tum.`in`.tumcampusapp.component.tumui.tutionfees.TuitionFeesFragment
import de.tum.`in`.tumcampusapp.component.ui.barrierfree.BarrierFreeInfoFragment
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.fragment.CafeteriaFragment
import de.tum.`in`.tumcampusapp.component.ui.cafeteriarating.CreateCafeteriaRatingFragment
import de.tum.`in`.tumcampusapp.component.ui.cafeteriarating.ShowCafeteriaRatingsFragment
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating.CreateCafeteriaRatingFragment
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating.ShowCafeteriaRatingsFragment
import de.tum.`in`.tumcampusapp.component.ui.chat.ChatRoomsFragment
import de.tum.`in`.tumcampusapp.component.ui.news.NewsFragment
import de.tum.`in`.tumcampusapp.component.ui.openinghour.OpeningHoursListFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CafeteriaMenuCard(context: Context, private val cafeteria: CafeteriaWithMe
@JvmStatic
fun inflateViewHolder(parent: ViewGroup, interactionListener: CardInteractionListener): CardViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.card_cafeteria_menu, parent, false)
return CafeteriaMenuViewHolder(view, interactionListener)
return CafeteriaMenuViewHolder(view, interactionListener)//,requireA)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteria

import android.content.Intent
import android.view.View
import android.widget.TextView
import androidx.core.content.ContentProviderCompat.requireContext
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import de.tum.`in`.tumcampusapp.R
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.details.CafeteriaMenusAdapter
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.details.OpenHoursHelper
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.model.CafeteriaWithMenus
import de.tum.`in`.tumcampusapp.component.ui.cafeteriarating.CreateCafeteriaRatingActivity
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating.CreateCafeteriaRatingFragment
import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener
import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder
import org.joda.time.format.DateTimeFormat
Expand Down Expand Up @@ -44,10 +44,20 @@ class CafeteriaMenuViewHolder(
menusRecyclerView.layoutManager = LinearLayoutManager(context)
menusRecyclerView.itemAnimator = DefaultItemAnimator()

/* adapter = CafeteriaMenusAdapter(context, false) { /*performClick()*/
val intent = Intent(requireContext, CreateCafeteriaRatingActivity::class.java)
context.startActivity(intent)
}*/
val lambda= { /*performClick()*/
// val intent = Intent(requireContext, CreateCafeteriaRatingActivity::class.java)
// context.startActivity(intent)
val nextFrag = CreateCafeteriaRatingFragment()
val help= itemView.context

(context as Fragment).requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.contentFrame, nextFrag, "cafeteriaRating")
.addToBackStack(null)
.commit()
}

adapter = CafeteriaMenusAdapter(context, false)//,lambda)

menusRecyclerView.adapter = adapter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding
import de.tum.`in`.tumcampusapp.R
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.model.CafeteriaMenu
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating.CreateCafeteriaRatingFragment
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating.ShowCafeteriaRatingsFragment
import de.tum.`in`.tumcampusapp.databinding.FragmentCafeteriadetailsSectionBinding
import de.tum.`in`.tumcampusapp.di.ViewModelFactory
import de.tum.`in`.tumcampusapp.di.injector
Expand Down Expand Up @@ -70,7 +72,15 @@ class CafeteriaDetailsSectionFragment : Fragment() {
menusRecyclerView.layoutManager = LinearLayoutManager(requireContext())
menusRecyclerView.itemAnimator = DefaultItemAnimator()

val adapter = CafeteriaMenusAdapter(requireContext(), true, null)
val adapter = CafeteriaMenusAdapter(requireContext(), true
) {
val nextFrag = ShowCafeteriaRatingsFragment()

requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.contentFrame, nextFrag, "cafeteriaRating")
.addToBackStack(null)
.commit()
}
menusRecyclerView.adapter = adapter

cafeteriaViewModel.cafeteriaMenus.observe(viewLifecycleOwner, Observer<List<CafeteriaMenu>> { adapter.update(it) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package de.tum.`in`.tumcampusapp.component.ui.cafeteria.details
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.fragment.app.Fragment
import de.tum.`in`.tumcampusapp.R
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.CafeteriaMenuFormatter
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.FavoriteDishDao
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.model.CafeteriaMenu
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.model.FavoriteDish
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating.CreateCafeteriaRatingFragment
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat

Expand All @@ -32,7 +34,16 @@ sealed class CafeteriaMenuAdapterItem {
val headerTextView = findViewById<TextView>(R.id.headerTextView)

headerTextView.text = menu.typeLong.replace("[0-9]", "").trim()
setOnClickListener { listener?.invoke() }
setOnClickListener {
listener?.invoke()
/* val nextFrag = CreateCafeteriaRatingFragment()
val help= it.context
(context as Fragment).requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.contentFrame, nextFrag, "cafeteriaRating")
.addToBackStack(null)
.commit()*/
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package de.tum.`in`.tumcampusapp.component.ui.cafeteria.details

import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -94,9 +95,10 @@ class CafeteriaMenusAdapter(

class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
init {
itemView.setBackgroundColor(0x80808)
itemView.setOnClickListener({
// itemView.findViewById<TextView>(R.id.nameTextView).text = "clicked"

Log.d("help", "test: ")
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import de.tum.`in`.tumcampusapp.component.ui.cafeteria.controller.CafeteriaManag
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.details.CafeteriaDetailsSectionsPagerAdapter
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.model.Cafeteria
import de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating.CreateCafeteriaRatingFragment
import de.tum.`in`.tumcampusapp.databinding.FragmentCafeteriaBinding
import de.tum.`in`.tumcampusapp.di.ViewModelFactory
import de.tum.`in`.tumcampusapp.di.injector
import de.tum.`in`.tumcampusapp.service.DownloadWorker
import de.tum.`in`.tumcampusapp.utils.Const
import de.tum.`in`.tumcampusapp.utils.Utils
import de.tum.`in`.tumcampusapp.utils.observeNonNull
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.joda.time.DateTime
import javax.inject.Inject
import javax.inject.Provider
Expand Down Expand Up @@ -84,6 +86,14 @@ class CafeteriaFragment : FragmentForDownloadingExternal(
binding.spinnerToolbar.adapter = adapter
binding.spinnerToolbar.onItemSelectedListener = this

binding.floatingActionButton.onClick {
val nextFrag = CreateCafeteriaRatingFragment()
requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.contentFrame, nextFrag, "cafeteriaRating")
.addToBackStack(null)
.commit()
}

cafeteriaViewModel.cafeterias.observeNonNull(this) { updateCafeterias(it) }
cafeteriaViewModel.selectedCafeteria.observeNonNull(this) { onNewCafeteriaSelected(it) }
cafeteriaViewModel.menuDates.observeNonNull(this) { updateSectionsPagerAdapter(it) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteriarating
package de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating


import android.Manifest
Expand All @@ -19,14 +19,12 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding
import de.tum.`in`.tumcampusapp.R
import de.tum.`in`.tumcampusapp.component.other.generic.fragment.FragmentForAccessingTumCabe
import de.tum.`in`.tumcampusapp.component.tumui.feedback.FeedbackContract
import de.tum.`in`.tumcampusapp.component.tumui.feedback.FeedbackPresenter
import de.tum.`in`.tumcampusapp.databinding.FragmentCafeteriaRatingBinding
import de.tum.`in`.tumcampusapp.utils.ImageUtils
import de.tum.`in`.tumcampusapp.utils.Utils
import java.io.File
import java.io.IOException
import javax.inject.Inject


class CreateCafeteriaRatingFragment : FragmentForAccessingTumCabe<List<String>>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteriarating
package de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating

import android.view.LayoutInflater
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteriarating
package de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating

class CreateTagRatingElement {
var tagLabel: String="label"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteriarating
package de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating

import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.recyclerview.widget.LinearLayoutManager
import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteriarating
package de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating

import android.content.Context
import android.content.res.ColorStateList
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteriarating
package de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating

class ShowRatingAverage(
var img: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.`in`.tumcampusapp.component.ui.cafeteriarating
package de.tum.`in`.tumcampusapp.component.ui.cafeteria.rating

class ShowTagRatingAverage(
var tagLabel: String,
Expand Down

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions app/src/main/res/layout/activity_cafeteria_rating.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/layout/activity_show_cafeteria_ratings.xml

This file was deleted.

37 changes: 30 additions & 7 deletions app/src/main/res/layout/fragment_cafeteria.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
Expand All @@ -28,9 +32,13 @@

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:transitionName="@string/transition_card"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
tools:ignore="UnusedAttribute">

<include
Expand All @@ -46,4 +54,19 @@

</LinearLayout>

</LinearLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/material_default_padding"
android:layout_marginBottom="@dimen/material_default_padding"
android:backgroundTint="@color/tum_blue"
android:clickable="true"
android:src="@drawable/ic_add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:tint="@color/white" />


</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 1 addition & 3 deletions app/src/main/res/layout/fragment_cafeteria_rating.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".component.ui.cafeteriarating.CreateCafeteriaRatingFragment">
tools:context=".component.ui.cafeteria.rating.CreateCafeteriaRatingFragment">

<include
android:id="@+id/include"
Expand Down Expand Up @@ -127,8 +127,6 @@

</LinearLayout>
</ScrollView>


</LinearLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:backgroundTint="@color/design_default_color_secondary"
tools:context=".component.ui.cafeteriarating.CreateCafeteriaRatingFragment">
tools:context=".component.ui.cafeteria.rating.CreateCafeteriaRatingFragment">

<include layout="@layout/toolbar" />

Expand Down

0 comments on commit 9690be4

Please sign in to comment.