From d3a90d75aab43553d1090c76e88d9a92725bf17b Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:21:12 +0200 Subject: [PATCH 01/22] dismanteled a few internals --- .../ui/ticket/BoughtTicketViewHolder.kt | 13 ------------- .../component/ui/ticket/EventCard.kt | 3 +-- .../component/ui/ticket/EventCardsProvider.kt | 17 ++--------------- .../component/ui/ticket/EventDiffUtil.kt | 17 ----------------- .../ui/ticket/adapter/EventsAdapter.kt | 9 --------- 5 files changed, 3 insertions(+), 56 deletions(-) delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDiffUtil.kt diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt index 4551d09c73..fd35f3bdb6 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt @@ -1,24 +1,11 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket import android.view.View -import android.widget.TextView import androidx.recyclerview.widget.RecyclerView -import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo -import de.tum.`in`.tumcampusapp.utils.Utils class BoughtTicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - private val amountTextView: TextView by lazy { itemView.findViewById(R.id.ticket_amount) } - private val ticketTypeNameTextView: TextView by lazy { itemView.findViewById(R.id.ticket_type_name) } - private val ticketPriceTextView: TextView by lazy { itemView.findViewById(R.id.price_per_ticket) } - fun bind(ticketInfo: TicketInfo) { - amountTextView.text = itemView.context.getString(R.string.amount_x, ticketInfo.count) - ticketTypeNameTextView.text = ticketInfo.ticketType?.description - ticketPriceTextView.text = itemView.context.getString( - R.string.price_per_ticket, - Utils.formatPrice(ticketInfo.ticketType?.price ?: 0) - ) } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt index 44c7d50864..73efd2ad9d 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt @@ -15,7 +15,6 @@ import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.EventDetailsActivity import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.EventsAdapter import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsLocalRepository import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository import de.tum.`in`.tumcampusapp.component.ui.tufilm.KinoActivity import de.tum.`in`.tumcampusapp.database.TcaDb @@ -26,7 +25,7 @@ class EventCard(context: Context) : Card(CardManager.CardTypes.EVENT, context) { var event: Event? = null // TODO(thellmund) Inject this - private val eventCardsProvider = EventCardsProvider(context, EventsLocalRepository(TcaDb.getInstance(context))) + private val eventCardsProvider = EventCardsProvider() private val localRepo = TicketsLocalRepository(TcaDb.getInstance(context)) override fun updateViewHolder(viewHolder: RecyclerView.ViewHolder) { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt index db99757337..83ba4558b9 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt @@ -1,31 +1,18 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket -import android.content.Context import de.tum.`in`.tumcampusapp.api.tumonline.CacheControl import de.tum.`in`.tumcampusapp.component.ui.overview.card.Card import de.tum.`in`.tumcampusapp.component.ui.overview.card.ProvidesCard -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsLocalRepository import java.util.* import javax.inject.Inject class EventCardsProvider @Inject -constructor(private val context: Context, private val localRepository: EventsLocalRepository) : ProvidesCard { +constructor() : ProvidesCard { fun setDismissed(id: Int) { - localRepository.setDismissed(id) } override fun getCards(cacheControl: CacheControl): List { - val results = ArrayList() - - // Add the next upcoming event that is not the next kino event - val event = localRepository.getNextEventWithoutMovie() - if (event != null) { - val eventCard = EventCard(context) - eventCard.event = event - results.add(eventCard) - } - - return results + return ArrayList() } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDiffUtil.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDiffUtil.kt deleted file mode 100644 index 4c8d8730ec..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDiffUtil.kt +++ /dev/null @@ -1,17 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import androidx.recyclerview.widget.DiffUtil -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventItem - -class EventDiffUtil( - private val oldItems: List, - private val newItems: List -) : DiffUtil.Callback() { - - override fun getOldListSize() = oldItems.size - override fun getNewListSize() = newItems.size - - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = oldItems[oldItemPosition].getIdForComparison() == newItems[newItemPosition].getIdForComparison() - - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = oldItems[oldItemPosition] == newItems[newItemPosition] -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt index bd046b954e..42e926bc99 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt @@ -11,7 +11,6 @@ import android.widget.ProgressBar import android.widget.TextView import androidx.constraintlayout.widget.Group import androidx.core.view.isVisible -import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.google.android.material.button.MaterialButton import com.squareup.picasso.Callback @@ -20,7 +19,6 @@ import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder import de.tum.`in`.tumcampusapp.component.ui.ticket.EventCard -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventDiffUtil import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.ShowTicketActivity import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventBetaInfo @@ -84,13 +82,6 @@ class EventsAdapter(private val mContext: Context) : RecyclerView.Adapter) { - if (newEvents.isEmpty() || newEvents[0] !is EventBetaInfo) { - newEvents.add(0, betaInfo) - } - val callback = EventDiffUtil(events, newEvents) - val diffResult = DiffUtil.calculateDiff(callback) - events = newEvents - diffResult.dispatchUpdatesTo(this) } class EventViewHolder( From 87237be567df14a0b638da08cadfdc130e7a146a Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:26:39 +0200 Subject: [PATCH 02/22] remvoed internals --- .../ui/overview/card/CardViewHolder.kt | 52 ------ .../component/ui/ticket/EventCard.kt | 13 -- .../component/ui/ticket/EventHelper.kt | 22 +-- .../ticket/fragment/EventDetailsFragment.kt | 157 +----------------- .../ui/tufilm/KinoDetailsFragment.kt | 146 ---------------- 5 files changed, 2 insertions(+), 388 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/CardViewHolder.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/CardViewHolder.kt index 574085b796..8efc57a3c7 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/CardViewHolder.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/CardViewHolder.kt @@ -1,16 +1,9 @@ package de.tum.`in`.tumcampusapp.component.ui.overview.card import android.content.Context -import android.view.Gravity -import android.view.MenuItem import android.view.View -import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity -import androidx.appcompat.widget.PopupMenu import androidx.recyclerview.widget.RecyclerView -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.navigation.NavigationManager -import de.tum.`in`.tumcampusapp.component.other.settings.SettingsActivity import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener open class CardViewHolder @JvmOverloads constructor( @@ -23,49 +16,4 @@ open class CardViewHolder @JvmOverloads constructor( private val context: Context by lazy { itemView.context } protected val activity: AppCompatActivity by lazy { context as AppCompatActivity } - - init { - itemView.setOnClickListener { - val destination = currentCard?.getNavigationDestination() ?: return@setOnClickListener - NavigationManager.open(activity, destination) - } - - val moreIcon = itemView.findViewById(R.id.cardMoreIcon) - moreIcon?.setOnClickListener { openOptionsPopup(it) } - } - - private fun openOptionsPopup(anchorView: View) { - val card = currentCard ?: return - - PopupMenu(context, anchorView, Gravity.END).apply { - menuInflater.inflate(card.optionsMenuResId, menu) - setOnMenuItemClickListener { onOptionSelected(it) } - show() - } - } - - private fun onOptionSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.open_card_setting -> openCardSettings() - R.id.always_hide_card -> alwaysHideCard() - } - - return true - } - - private fun openCardSettings() { - val resId = currentCard?.cardType?.showCardPreferenceStringRes ?: return - val key = context.getString(resId) - val intent = SettingsActivity.newIntent(context, key) - context.startActivity(intent) - } - - private fun alwaysHideCard() { - if (adapterPosition != RecyclerView.NO_POSITION) { - listener?.onAlwaysHideCard(adapterPosition) - } - - currentCard?.hideAlways() - currentCard?.discard() - } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt index 73efd2ad9d..7ce99630a3 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt @@ -5,7 +5,6 @@ import android.content.SharedPreferences import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.other.navigation.NavDestination import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener @@ -28,18 +27,6 @@ class EventCard(context: Context) : Card(CardManager.CardTypes.EVENT, context) { private val eventCardsProvider = EventCardsProvider() private val localRepo = TicketsLocalRepository(TcaDb.getInstance(context)) - override fun updateViewHolder(viewHolder: RecyclerView.ViewHolder) { - super.updateViewHolder(viewHolder) - - val eventViewHolder = viewHolder as? EventsAdapter.EventViewHolder ?: return - - val event = this.event - if (event != null) { - val ticketCount = event.let { localRepo.getTicketCount(it) } - eventViewHolder.bind(event, ticketCount) - } - } - override fun getNavigationDestination(): NavDestination { val event = this.event if (event != null && event.kino != -1) { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt index 33ba80df30..5dec8eb21d 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt @@ -2,9 +2,7 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket import android.view.View import android.widget.TextView -import androidx.core.view.isVisible import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketStatus -import java.util.Locale /** * Logic associated with the buy button that is needed in the EventDetailsFragment @@ -20,24 +18,6 @@ class EventHelper { remainingTicketsContainer: View, remainingTicketsTextView: TextView, noTicketsMessage: String - ) { - if (isEventImminent) { - buyTicketButton.isVisible = isEventBooked - remainingTicketsContainer.isVisible = false - } else { - if (status == null || status.isEventWithoutTickets()) { - buyTicketButton.isVisible = isEventBooked - remainingTicketsContainer.isVisible = false - } else if (status.ticketsStillAvailable()) { - buyTicketButton.isVisible = true - remainingTicketsContainer.isVisible = true - remainingTicketsTextView.text = String.format(Locale.getDefault(), "%d", status.getRemainingTicketCount()) - } else { - buyTicketButton.isVisible = isEventBooked - remainingTicketsContainer.isVisible = true - remainingTicketsTextView.text = noTicketsMessage - } - } - } + ) { } } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt index 2670d15013..753ee9bace 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt @@ -1,30 +1,18 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.fragment -import android.content.Intent -import android.net.Uri import android.os.Bundle -import android.provider.CalendarContract import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import androidx.swiperefreshlayout.widget.SwipeRefreshLayout -import com.squareup.picasso.Picasso import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.tumui.calendar.CreateEventActivity -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventHelper -import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.ShowTicketActivity import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketStatus import de.tum.`in`.tumcampusapp.databinding.FragmentEventDetailsBinding import de.tum.`in`.tumcampusapp.di.ViewModelFactory import de.tum.`in`.tumcampusapp.utils.Const -import de.tum.`in`.tumcampusapp.utils.Const.KEY_EVENT_ID -import de.tum.`in`.tumcampusapp.utils.DateTimeUtils -import de.tum.`in`.tumcampusapp.utils.ThemedAlertDialogBuilder -import de.tum.`in`.tumcampusapp.utils.into import javax.inject.Inject import javax.inject.Provider @@ -34,10 +22,6 @@ import javax.inject.Provider */ class EventDetailsFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { - private val event: Event by lazy { - arguments?.getParcelable(Const.KEY_EVENT) ?: throw IllegalStateException("No event provided to EventDetailsFragment") - } - private val viewModel: EventDetailsViewModel by lazy { val factory = ViewModelFactory(viewModelProviders) ViewModelProvider(this, factory).get(EventDetailsViewModel::class.java) @@ -53,155 +37,16 @@ class EventDetailsFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - val view = LayoutInflater.from(container?.context) - .inflate(R.layout.fragment_event_details, container, false) - - binding.swipeRefreshLayout.setOnRefreshListener(this) - binding.swipeRefreshLayout.setColorSchemeResources( - R.color.color_primary, - R.color.tum_A100, - R.color.tum_A200 - ) - return view + return LayoutInflater.from(container?.context).inflate(R.layout.fragment_event_details, container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - showEventDetails(event) - viewModel.aggregatedTicketStatus.observe(viewLifecycleOwner) { showTicketCount(it) } } override fun onRefresh() { viewModel.fetchTicketCount() } - private fun showEventDetails(event: Event) { - val url = event.imageUrl - with(binding) { - if (url != null) { - Picasso.get() - .load(url) - .noPlaceholder() - .into(posterView) { - posterProgressBar.visibility = View.GONE - } - } else { - posterProgressBar.visibility = View.GONE - } - - if (viewModel.isEventBooked(event)) { - ticketButton.text = getString(R.string.show_ticket) - ticketButton.text = resources.getQuantityText(R.plurals.show_tickets, viewModel.getBookedTicketCount(event)) - ticketButton.setOnClickListener { showTicket(event) } - } - - context?.let { - dateTextView.text = event.getFormattedStartDateTime(it) - dateContainer.setOnClickListener { displayAddToCalendarDialog() } - } - - locationTextView.text = event.locality - locationContainer.setOnClickListener { openMaps(event) } - - descriptionTextView.text = event.description - - linkButton.setOnClickListener { openEventLink(event) } - linkButton.visibility = if (event.eventUrl.isNotBlank()) View.VISIBLE else View.GONE - } - } - - private fun openEventLink(event: Event) { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(event.eventUrl)) - startActivity(intent) - } - - private fun showTicketCount(status: TicketStatus?) { - with(binding) { - EventHelper.showRemainingTickets( - status, - viewModel.isEventBooked(event), - true, - ticketButton, - remainingTicketsContainer, - remainingTicketsTextView, - getString(R.string.no_tickets_remaining_message) - ) - - swipeRefreshLayout.isRefreshing = false - } - } - - private fun showTicket(event: Event) { - val intent = Intent(context, ShowTicketActivity::class.java).apply { - putExtra(KEY_EVENT_ID, event.id) - } - startActivity(intent) - } - - private fun addToTUMCalendar() { - val event = event - val endTime = event.endTime ?: event.startTime.plus(Event.defaultDuration.toLong()) - - val intent = Intent(context, CreateEventActivity::class.java).apply { - putExtra(Const.EVENT_EDIT, false) - putExtra(Const.EVENT_TITLE, event.title) - putExtra(Const.EVENT_COMMENT, event.description) - putExtra(Const.EVENT_START, event.startTime) - putExtra(Const.EVENT_END, endTime) - } - - startActivity(intent) - } - - private fun addToExternalCalendar() { - val event = event - val endTime = event.endTime ?: event.startTime.plus(Event.defaultDuration.toLong()) - val eventEnd = DateTimeUtils.getDateTimeString(endTime) - - val intent = Intent(Intent.ACTION_INSERT).apply { - data = CalendarContract.Events.CONTENT_URI - putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, event.startTime.millis) - putExtra(CalendarContract.EXTRA_EVENT_END_TIME, eventEnd) - putExtra(CalendarContract.Events.TITLE, event.title) - putExtra(CalendarContract.Events.DESCRIPTION, event.description) - putExtra(CalendarContract.Events.EVENT_LOCATION, event.locality) - // Indicates that this event is free time and will not conflict with other events - putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_FREE) - } - - startActivity(intent) - } - - private fun openMaps(event: Event) { - val url = "http://maps.google.co.in/maps?q=${event.locality}" - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) - startActivity(intent) - } - - private fun displayAddToCalendarDialog() { - val context = requireContext() - - val calendars = arrayOf( - getString(R.string.external_calendar), - getString(R.string.tum_calendar) - ) - - ThemedAlertDialogBuilder(context) - .setTitle(R.string.add_to_calendar_info) - .setSingleChoiceItems(calendars, 0, null) - .setNegativeButton(R.string.cancel, null) - .setPositiveButton(R.string.add) { _, which -> handleCalendarExportSelection(which) } - .setCancelable(true) - .show() - } - - private fun handleCalendarExportSelection(which: Int) { - when (which) { - 0 -> addToExternalCalendar() - else -> addToTUMCalendar() - } - } - companion object { @JvmStatic diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt index 7feeadd17d..5d384f7f76 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt @@ -1,34 +1,16 @@ package de.tum.`in`.tumcampusapp.component.ui.tufilm import android.content.Context -import android.content.Intent -import android.graphics.Bitmap -import android.graphics.PorterDuff -import android.graphics.drawable.Drawable -import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.TextView -import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProvider -import com.squareup.picasso.Picasso -import com.squareup.picasso.Target import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventHelper -import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.ShowTicketActivity -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketStatus import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository -import de.tum.`in`.tumcampusapp.component.ui.tufilm.model.Kino import de.tum.`in`.tumcampusapp.databinding.FragmentKinodetailsSectionBinding -import de.tum.`in`.tumcampusapp.di.ViewModelFactory import de.tum.`in`.tumcampusapp.utils.Const -import de.tum.`in`.tumcampusapp.utils.Const.KEY_EVENT_ID import javax.inject.Inject import javax.inject.Provider @@ -37,8 +19,6 @@ import javax.inject.Provider */ class KinoDetailsFragment : Fragment() { - private var event: Event? = null - @Inject internal lateinit var viewModelProvider: Provider @@ -51,16 +31,6 @@ class KinoDetailsFragment : Fragment() { override fun onAttach(context: Context) { super.onAttach(context) - (requireActivity() as BaseActivity).injector - .kinoComponent() - .inject(this) - - val factory = ViewModelFactory(viewModelProvider) - kinoViewModel = ViewModelProvider(this, factory).get(KinoDetailsViewModel::class.java) - - kinoViewModel.kino.observe(this) { showMovieDetails(it) } - kinoViewModel.event.observe(this) { showEventTicketDetails(it) } - kinoViewModel.aggregatedTicketStatus.observe(this) { showTicketCount(it) } } override fun onCreateView( @@ -69,122 +39,6 @@ class KinoDetailsFragment : Fragment() { savedInstanceState: Bundle? ): View = inflater.inflate(R.layout.fragment_kinodetails_section, container, false) - override fun onResume() { - super.onResume() - event?.let { - initBuyOrShowTicket(it) - } - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val position = arguments?.getInt(Const.POSITION) ?: 0 - kinoViewModel.fetchKinoByPosition(position) - } - - private fun showEventTicketDetails(event: Event) { - this.event = event - initBuyOrShowTicket(event) - - with(binding) { - eventInformation.visibility = View.VISIBLE - locationTextView.text = event.locality - } - - kinoViewModel.fetchTicketCount(event.id) - } - - private fun initBuyOrShowTicket(event: Event) { - val ticketBoughtCount = ticketsLocalRepo.getTicketCount(event) - - if (ticketBoughtCount > 0) { - binding.buyTicketButton.text = resources.getQuantityString(R.plurals.show_tickets, ticketBoughtCount) - binding.buyTicketButton.setOnClickListener { - val intent = Intent(context, ShowTicketActivity::class.java).apply { - putExtra(KEY_EVENT_ID, event.id) - } - startActivity(intent) - } - } - } - - private fun showTicketCount(status: TicketStatus?) { - val event = event - val isEventBooked = event != null && ticketsLocalRepo.getTicketCount(event) > 0 - - with(binding) { - EventHelper.showRemainingTickets( - status, - isEventBooked, - true, - buyTicketButton, - remainingTicketsContainer, - remainingTicketsTextView, - getString(R.string.no_tickets_remaining_tufilm_message) - ) - } - } - - private fun showMovieDetails(kino: Kino) { - kinoViewModel.fetchEventByMovieId(kino.id) - - loadPoster(kino) - - with(binding) { - kinoMovieTitle.text = kino.title.split(":".toRegex(), 2).toTypedArray()[1] - dateTextView.text = kino.formattedShortDate - runtimeTextView.text = kino.runtime - ratingTextView.text = kino.formattedRating - - val colorPrimary = ContextCompat.getColor(requireContext(), R.color.color_primary) - setCompoundDrawablesTint(dateTextView, colorPrimary) - setCompoundDrawablesTint(runtimeTextView, colorPrimary) - setCompoundDrawablesTint(ratingTextView, colorPrimary) - - descriptionTextView.text = kino.formattedDescription - genresTextView.text = kino.genre - releaseYearTextView.text = kino.year - actorsTextView.text = kino.actors - directorTextView.text = kino.director - - moreInfoButton.setOnClickListener { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(kino.link)) - startActivity(intent) - } - } - } - - private fun loadPoster(kino: Kino) { - binding.trailerButton.setOnClickListener { showTrailer(kino) } - - Picasso.get() - .load(kino.cover) - .into(object : Target { - override fun onBitmapLoaded(bitmap: Bitmap, from: Picasso.LoadedFrom) { - binding.kinoCoverPlaceholder.visibility = View.GONE - binding.kinoCover.setImageBitmap(bitmap) - } - override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) { - binding.kinoCoverProgress.visibility = View.GONE - } - override fun onPrepareLoad(placeHolderDrawable: Drawable?) { - // intentionally left blank - } - }) - } - - private fun setCompoundDrawablesTint(textView: TextView, color: Int) { - for (drawable in textView.compoundDrawables) { - drawable?.setColorFilter(color, PorterDuff.Mode.SRC_ATOP) - } - } - - private fun showTrailer(kino: Kino) { - val url = kino.trailerSearchUrl - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) - requireActivity().startActivity(intent) - } - companion object { fun newInstance(position: Int): KinoDetailsFragment { From f4958bfe54b1bb554d39dfea66dee644af1d5f4f Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:30:44 +0200 Subject: [PATCH 03/22] remvoed internals --- .../component/ui/ticket/EventCard.kt | 10 ++-------- .../activity/PaymentConfirmationActivity.kt | 19 ------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt index 7ce99630a3..d6b828d043 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt @@ -11,7 +11,6 @@ import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener import de.tum.`in`.tumcampusapp.component.ui.overview.CardManager import de.tum.`in`.tumcampusapp.component.ui.overview.card.Card import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.EventDetailsActivity import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.EventsAdapter import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository @@ -28,13 +27,8 @@ class EventCard(context: Context) : Card(CardManager.CardTypes.EVENT, context) { private val localRepo = TicketsLocalRepository(TcaDb.getInstance(context)) override fun getNavigationDestination(): NavDestination { - val event = this.event - if (event != null && event.kino != -1) { - val args = Bundle().apply { putInt(Const.KINO_ID, event.kino) } - return NavDestination.Activity(KinoActivity::class.java, args) - } - val args = Bundle().apply { putParcelable(Const.KEY_EVENT, event) } - return NavDestination.Activity(EventDetailsActivity::class.java, args) + val args = Bundle().apply { putInt(Const.KINO_ID, 1) } + return NavDestination.Activity(KinoActivity::class.java, args) } override fun shouldShow(prefs: SharedPreferences): Boolean { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt index 7145c564cf..1ef1a409de 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt @@ -37,14 +37,6 @@ class PaymentConfirmationActivity : BaseActivity(R.layout.activity_payment_confi startActivity(intent) } - binding.doneButton.setOnClickListener { - val intent = Intent(this, EventsActivity::class.java).apply { - addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - } - startActivity(intent) - finish() - } - runCheckmarkAnimation() } @@ -60,7 +52,6 @@ class PaymentConfirmationActivity : BaseActivity(R.layout.activity_payment_confi override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { android.R.id.home -> { - handleOnBackPressed() true } else -> super.onOptionsItemSelected(item) @@ -68,15 +59,5 @@ class PaymentConfirmationActivity : BaseActivity(R.layout.activity_payment_confi } override fun onBackPressed() { - handleOnBackPressed() - } - - private fun handleOnBackPressed() { - // Go back to events and finish this activity to prevent the user from purchasing - // another ticket. - val intent = Intent(this, EventsActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - startActivity(intent) - finish() } } From 9786b13857463e81ba6c2c2228d2cc12b889ef95 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:34:41 +0200 Subject: [PATCH 04/22] removed the event downloading --- .../api/app/TUMCabeAPIService.java | 5 -- .../tumcampusapp/api/app/TUMCabeClient.java | 17 ------ .../component/ui/ticket/EventCard.kt | 3 - .../ui/ticket/EventsDownloadAction.kt | 6 +- .../ui/ticket/activity/ShowTicketActivity.kt | 20 ------- .../repository/EventsLocalRepository.kt | 4 -- .../repository/EventsRemoteRepository.kt | 56 +------------------ .../repository/TicketsRemoteRepository.kt | 27 --------- .../tumcampusapp/service/di/DownloadModule.kt | 2 +- 9 files changed, 3 insertions(+), 137 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java index 944b033b58..399c82b4f5 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java @@ -121,11 +121,6 @@ public interface TUMCabeAPIService { /// This endpoint won't be avaliable in the v2 backend Observable> getEvents(); - // Getting Ticket information - @POST(API_EVENTS + API_TICKET + "my") - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - Observable> getTickets(@Body TUMCabeVerification verification); @POST(API_EVENTS + API_TICKET + "{ticketID}") @Deprecated diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java index 41c68a2ced..1afb7693a3 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java @@ -226,23 +226,6 @@ public Call> getStudyRoomGroups() { } // TICKET SALE - - // Getting event information - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - public Observable> fetchEvents() { - return service.getEvents(); - } - - // Getting ticket information - - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - public Observable> fetchTickets(Context context) throws NoPrivateKey { - TUMCabeVerification verification = getVerification(context, null); - return service.getTickets(verification); - } - @Deprecated /// This endpoint won't be avaliable in the v2 backend public Call fetchTicket(Context context, int ticketID) throws NoPrivateKey { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt index d6b828d043..392f443c23 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt @@ -13,9 +13,7 @@ import de.tum.`in`.tumcampusapp.component.ui.overview.card.Card import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.EventsAdapter import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository import de.tum.`in`.tumcampusapp.component.ui.tufilm.KinoActivity -import de.tum.`in`.tumcampusapp.database.TcaDb import de.tum.`in`.tumcampusapp.utils.Const class EventCard(context: Context) : Card(CardManager.CardTypes.EVENT, context) { @@ -24,7 +22,6 @@ class EventCard(context: Context) : Card(CardManager.CardTypes.EVENT, context) { // TODO(thellmund) Inject this private val eventCardsProvider = EventCardsProvider() - private val localRepo = TicketsLocalRepository(TcaDb.getInstance(context)) override fun getNavigationDestination(): NavDestination { val args = Bundle().apply { putInt(Const.KINO_ID, 1) } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt index 79d55f3395..e2777e6b0a 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt @@ -1,15 +1,11 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket import de.tum.`in`.tumcampusapp.api.tumonline.CacheControl -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsRemoteRepository import de.tum.`in`.tumcampusapp.service.DownloadWorker import javax.inject.Inject -class EventsDownloadAction @Inject constructor( - private val eventsRemoteRepository: EventsRemoteRepository -) : DownloadWorker.Action { +class EventsDownloadAction @Inject constructor() : DownloadWorker.Action { override fun execute(cacheBehaviour: CacheControl) { - eventsRemoteRepository.fetchEventsAndTickets() } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt index 8072b32bc4..a46fe4aab9 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt @@ -104,29 +104,9 @@ class ShowTicketActivity : BaseActivity(R.layout.activity_show_ticket) { R.color.tum_A100, R.color.tum_A200 ) - swipeRefreshLayout.setOnRefreshListener { loadRedemptionStatus() } } } - private fun loadRedemptionStatus() { - val disposable = ticketsRemoteRepo - .fetchTickets() - .subscribe({ handleTicketRefreshSuccess(it) }, { handleTicketRefreshFailure() }) - compositeDisposable.add(disposable) - } - - private fun handleTicketRefreshSuccess(tickets: List) { - ticketsLocalRepo.insert(*tickets.toTypedArray()) - ticketInfoList = ticketsLocalRepo.getTicketsByEventId(event.id) - setViewData() - binding.swipeRefreshLayout.isRefreshing = false - } - - private fun handleTicketRefreshFailure() { - Utils.showToast(this, R.string.error_something_wrong) - binding.swipeRefreshLayout.isRefreshing = false - } - private fun loadTicketData(eventId: Int) { val ticketTypes = ticketsLocalRepo.getTicketTypesByEventId(eventId) if (ticketTypes.isEmpty()) { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt index 7237f09ec3..732c19f36b 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt @@ -13,10 +13,6 @@ class EventsLocalRepository @Inject constructor( database.eventDao().insert(events) } - fun setDismissed(id: Int) { - database.eventDao().setDismissed(id) - } - fun getEvents(): Observable> = database.eventDao().allFutureEvents fun getBookedEvents(): Observable> = database.eventDao().allBookedEvents diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt index e82d031ec8..f9709557e1 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt @@ -1,68 +1,14 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.repository -import android.annotation.SuppressLint -import android.content.Context import de.tum.`in`.tumcampusapp.api.app.TUMCabeClient -import de.tum.`in`.tumcampusapp.component.ui.chat.model.ChatMember -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketStatus -import de.tum.`in`.tumcampusapp.utils.Const.CHAT_MEMBER -import de.tum.`in`.tumcampusapp.utils.Utils -import io.reactivex.Completable -import io.reactivex.Observable import io.reactivex.Single -import io.reactivex.schedulers.Schedulers import javax.inject.Inject class EventsRemoteRepository @Inject constructor( - private val context: Context, - private val tumCabeClient: TUMCabeClient, - private val eventsLocalRepository: EventsLocalRepository, - private val ticketsLocalRepository: TicketsLocalRepository, - private val ticketsRemoteRepository: TicketsRemoteRepository + private val tumCabeClient: TUMCabeClient ) { - fun fetchEventsAndTickets() { - fetchAndStoreEvents() - - val isLoggedIn = Utils.getSetting(context, CHAT_MEMBER, ChatMember::class.java) != null - if (isLoggedIn) { - fetchAndStoreTickets() - } - } - - @SuppressLint("CheckResult") - private fun fetchAndStoreEvents() { - fetchEvents() - .subscribeOn(Schedulers.io()) - .subscribe(eventsLocalRepository::storeEvents, Utils::log) - } - - @SuppressLint("CheckResult") - private fun fetchAndStoreTickets() { - val tickets = ticketsRemoteRepository.fetchTickets().share() - - tickets.flatMapCompletable { storeTickets(it) } - .onErrorComplete() - .subscribe() - - tickets.flatMapCompletable { ticketsRemoteRepository.fetchTicketTypesForTickets(it) } - .onErrorComplete() - .subscribe() - } - - private fun storeTickets(tickets: List): Completable { - return Completable.fromCallable { - ticketsLocalRepository.storeTickets(tickets) - Completable.complete() - } - } - - fun fetchEvents(): Observable> { - return tumCabeClient.fetchEvents() - } - fun fetchTicketStats(eventId: Int): Single { return tumCabeClient.fetchTicketStats(eventId) .map { it.reduceRight { s, a -> TicketStatus(-1, a.contingent + s.contingent, a.sold + s.sold) } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt index c02dd3ebe2..527916e738 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt @@ -1,42 +1,15 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.repository -import android.content.Context import de.tum.`in`.tumcampusapp.api.app.TUMCabeClient -import de.tum.`in`.tumcampusapp.api.app.exception.NoPrivateKey -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType -import de.tum.`in`.tumcampusapp.utils.Utils -import io.reactivex.Completable import io.reactivex.Observable -import io.reactivex.schedulers.Schedulers -import retrofit2.Call import javax.inject.Inject class TicketsRemoteRepository @Inject constructor( - private val context: Context, private val tumCabeClient: TUMCabeClient, private val ticketsLocalRepository: TicketsLocalRepository ) { - fun fetchTickets(): Observable> { - return tumCabeClient - .fetchTickets(context) - .doOnError { Utils.log(it) } - .subscribeOn(Schedulers.io()) - } - - @Throws(NoPrivateKey::class) - fun fetchTicket(ticketId: Int): Call { - return tumCabeClient.fetchTicket(context, ticketId) - } - - fun fetchTicketTypesForTickets(tickets: List): Completable { - val sources = tickets.map { fetchTicketTypesForEvent(it.eventId) } - return Observable - .merge(sources) - .ignoreElements() - } - fun fetchTicketTypesForEvent(eventId: Int): Observable> { return tumCabeClient.fetchTicketTypes(eventId) .doOnNext(ticketsLocalRepository::addTicketTypes) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt index 44b7f3fb34..c8297a86a1 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt @@ -57,7 +57,7 @@ object DownloadModule { @Provides fun provideEventsDownloadAction( remoteRepository: EventsRemoteRepository - ): EventsDownloadAction = EventsDownloadAction(remoteRepository) + ): EventsDownloadAction = EventsDownloadAction() @JvmStatic @Provides From fd8dd9bf67967625816df3c0ba9d235377cd40b4 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:37:47 +0200 Subject: [PATCH 05/22] removed event type downloading --- .../api/app/TUMCabeAPIService.java | 5 ----- .../tumcampusapp/api/app/TUMCabeClient.java | 11 ---------- .../ui/ticket/activity/BuyTicketActivity.kt | 20 ------------------- .../ui/ticket/activity/ShowTicketActivity.kt | 4 ---- .../repository/TicketsLocalRepository.kt | 7 ------- .../repository/TicketsRemoteRepository.kt | 14 +------------ 6 files changed, 1 insertion(+), 60 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java index 399c82b4f5..74aaef639f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java @@ -127,11 +127,6 @@ public interface TUMCabeAPIService { /// This endpoint won't be avaliable in the v2 backend Call getTicket(@Path("ticketID") int ticketID, @Body TUMCabeVerification verification); - @GET(API_EVENTS + API_TICKET + "type/{eventID}") - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - Observable> getTicketTypes(@Path("eventID") int eventID); - // Ticket reservation @POST(API_EVENTS + API_TICKET + "reserve/multiple") @Deprecated diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java index 1afb7693a3..7eb3bea3ef 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java @@ -68,10 +68,6 @@ public final class TUMCabeClient { static final String API_BARRIER_FREE = "barrierfree/"; static final String API_BARRIER_FREE_CONTACT = "contacts/"; static final String API_BARRIER_FREE_MORE_INFO = "moreInformation/"; - static final String API_ROOM_FINDER = "roomfinder/room/"; - static final String API_ROOM_FINDER_COORDINATES = "coordinates/"; - static final String API_ROOM_FINDER_AVAILABLE_MAPS = "availableMaps/"; - static final String API_ROOM_FINDER_SCHEDULE = "scheduleById/"; static final String API_FEEDBACK = "feedback/"; static final String API_CAFETERIAS = "mensen/"; static final String API_KINOS = "kino/"; @@ -82,7 +78,6 @@ public final class TUMCabeClient { private static final String API_HOSTNAME = Const.API_HOSTNAME; private static final String API_BASEURL = "/Api/"; private static final String API_CHAT = "chat/"; - static final String API_CHAT_ROOMS = API_CHAT + "rooms/"; static final String API_CHAT_MEMBERS = API_CHAT + "members/"; static final String API_OPENING_HOURS = "openingtimes/"; @@ -233,12 +228,6 @@ public Call fetchTicket(Context context, int ticketID) throws NoPrivateK return service.getTicket(ticketID, verification); } - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - public Observable> fetchTicketTypes(int eventID) { - return service.getTicketTypes(eventID); - } - // Ticket reservation @Deprecated diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt index 385b38f6f6..7b95929085 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt @@ -21,9 +21,7 @@ import de.tum.`in`.tumcampusapp.databinding.ActivityBuyTicketBinding import de.tum.`in`.tumcampusapp.utils.Const import de.tum.`in`.tumcampusapp.utils.ThemedAlertDialogBuilder import de.tum.`in`.tumcampusapp.utils.Utils -import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable -import io.reactivex.schedulers.Schedulers import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -80,24 +78,6 @@ class BuyTicketActivity : BaseActivity(R.layout.activity_buy_ticket), TicketAmou eventId = intent.getIntExtra(Const.KEY_EVENT_ID, 0) binding.totalPriceTextView.text = Utils.formatPrice(0) - - // Get ticket type information from API - val disposable = ticketsRemoteRepo.fetchTicketTypesForEvent(eventId) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .doOnError { Utils.log(it) } - .subscribe({ handleTicketTypesDownloadSuccess(it) }, { - Utils.showToast(this@BuyTicketActivity, R.string.error_something_wrong) - finish() - }) - compositeDisposable.add(disposable) - } - - private fun handleTicketTypesDownloadSuccess(ticketTypes: List) { - this.ticketTypes = ticketTypes - - currentTicketAmounts = IntArray(ticketTypes.size) { 0 } - setupUi() } private fun setupUi() { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt index a46fe4aab9..dadbd699df 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt @@ -108,10 +108,6 @@ class ShowTicketActivity : BaseActivity(R.layout.activity_show_ticket) { } private fun loadTicketData(eventId: Int) { - val ticketTypes = ticketsLocalRepo.getTicketTypesByEventId(eventId) - if (ticketTypes.isEmpty()) { - ticketsLocalRepo.addTicketTypes(ticketsRemoteRepo.fetchTicketTypesForEvent(eventId).blockingSingle()) - } ticketInfoList = ticketsLocalRepo.getTicketsByEventId(eventId) val eventForId = eventsLocalRepo.getEventById(eventId) if (eventForId == null) { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt index 131e4ce4e3..513ee6593e 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt @@ -3,7 +3,6 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.repository import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType import de.tum.`in`.tumcampusapp.database.TcaDb import javax.inject.Inject @@ -20,12 +19,6 @@ class TicketsLocalRepository @Inject constructor( fun getTicketsByEventId(eventId: Int): List = database.ticketDao().getByEventId(eventId) - fun getTicketTypesByEventId(eventId: Int): List = database.ticketTypeDao().getByEventId(eventId) - - fun addTicketTypes(ticketTypes: List) { - database.ticketTypeDao().insert(ticketTypes) - } - fun getTicketCount(event: Event): Int { return database.ticketDao().getTicketCountForEvent(event.id) } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt index 527916e738..c6c9e2198e 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt @@ -1,17 +1,5 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.repository -import de.tum.`in`.tumcampusapp.api.app.TUMCabeClient -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType -import io.reactivex.Observable import javax.inject.Inject -class TicketsRemoteRepository @Inject constructor( - private val tumCabeClient: TUMCabeClient, - private val ticketsLocalRepository: TicketsLocalRepository -) { - - fun fetchTicketTypesForEvent(eventId: Int): Observable> { - return tumCabeClient.fetchTicketTypes(eventId) - .doOnNext(ticketsLocalRepository::addTicketTypes) - } -} +class TicketsRemoteRepository @Inject constructor() From 69fa4881d8cf0c64f1498dafeeddc7de0f6797c0 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:43:07 +0200 Subject: [PATCH 06/22] removed internals --- .../component/ui/ticket/EventsViewModel.kt | 103 +----------------- .../ui/ticket/fragment/EventsListFragment.kt | 4 - 2 files changed, 2 insertions(+), 105 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt index 16b183b3b4..b4b0bcc990 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt @@ -3,20 +3,9 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import com.jakewharton.rxrelay2.PublishRelay import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventType -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsLocalRepository -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsRemoteRepository -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsRemoteRepository import de.tum.`in`.tumcampusapp.utils.plusAssign -import io.reactivex.Completable -import io.reactivex.Observable import io.reactivex.disposables.CompositeDisposable -import io.reactivex.schedulers.Schedulers -import java.util.concurrent.TimeUnit import javax.inject.Inject sealed class Action { @@ -31,102 +20,14 @@ sealed class Result { object None : Result() } -class EventsViewModel @Inject constructor( - private val eventsLocalRepository: EventsLocalRepository, - private val eventsRemoteRepository: EventsRemoteRepository, - private val ticketsLocalRepository: TicketsLocalRepository, - private val ticketsRemoteRepository: TicketsRemoteRepository, - eventType: EventType -) : ViewModel() { +class EventsViewModel @Inject constructor() : ViewModel() { private val compositeDisposable = CompositeDisposable() - private val refreshRelay = PublishRelay.create() private val _viewState = MutableLiveData() val viewState: LiveData = _viewState - init { - val initialViewState = EventsViewState.initial() - - val eventsChanges = when (eventType) { - EventType.ALL -> eventsLocalRepository.getEvents() - EventType.BOOKED -> eventsLocalRepository.getBookedEvents() - } - - val databaseChanges = eventsChanges.map(Result::EventsLoaded) - val actions = refreshRelay.flatMap(this::processAction) - - compositeDisposable += Observable.merge(databaseChanges, actions) - .scan(initialViewState, this::reduceState) - .distinctUntilChanged() - .subscribe(this::render) - } - - private fun processAction(action: Action): Observable { - return when (action) { - is Action.Refresh -> fetchEventsAndTickets(action.isLoggedIn) - } - } - - private fun reduceState(viewState: EventsViewState, result: Result): EventsViewState { - return when (result) { - Result.ShowLoading -> viewState.toLoading() - is Result.EventsLoaded -> viewState.toEventsLoaded(result.events) - Result.ShowError -> viewState.toError() - Result.HideError -> viewState.toNoError() - Result.None -> viewState // no changes, we return the current view state - } - } - - private fun fetchEventsAndTickets(isLoggedIn: Boolean): Observable { - return loadAndStoreEvents() - .andThen(Observable.just(Result.None as Result)) - .startWith(Result.ShowLoading) - .doOnNext { loadAndStoreTickets(isLoggedIn) } - .onErrorResumeNext { t: Throwable -> showErrorForDuration(ERROR_DURATION) } - } - - private fun showErrorForDuration(duration: Long): Observable { - return Observable.timer(duration, TimeUnit.SECONDS, Schedulers.computation()) - .map { Result.HideError } - .startWith(Result.ShowError) - } - - private fun loadAndStoreEvents(): Completable { - return Observable - .fromCallable { eventsLocalRepository.removePastEventsWithoutTicket() } - .subscribeOn(Schedulers.io()) - .flatMap { eventsRemoteRepository.fetchEvents() } - .subscribeOn(Schedulers.io()) - .flatMapCompletable { - eventsLocalRepository.storeEvents(it) - Completable.complete() - } - } - - private fun loadAndStoreTickets(isLoggedIn: Boolean) { - if (isLoggedIn.not()) { - return - } - - compositeDisposable += ticketsRemoteRepository.fetchTickets() - .subscribeOn(Schedulers.io()) - .doOnNext { loadAndStoreTicketTypes(it) } - .flatMapCompletable { - ticketsLocalRepository.storeTickets(it) - Completable.complete() - } - .subscribe() - } - - private fun loadAndStoreTicketTypes(tickets: List) { - compositeDisposable += ticketsRemoteRepository.fetchTicketTypesForTickets(tickets) - .subscribeOn(Schedulers.io()) - .subscribe() - } - - fun refreshEventsAndTickets(isLoggedIn: Boolean) { - refreshRelay.accept(Action.Refresh(isLoggedIn)) + fun refreshEventsAndTickets() { } private fun render(viewState: EventsViewState) { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt index 7e9f8ae623..0f2ceda0dc 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt @@ -12,14 +12,12 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.other.generic.adapter.EqualSpacingItemDecoration -import de.tum.`in`.tumcampusapp.component.ui.chat.model.ChatMember import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsViewModel import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsViewState import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.EventsAdapter import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventType import de.tum.`in`.tumcampusapp.databinding.FragmentEventsListBinding import de.tum.`in`.tumcampusapp.di.ViewModelFactory -import de.tum.`in`.tumcampusapp.utils.Const.CHAT_MEMBER import de.tum.`in`.tumcampusapp.utils.Utils import de.tum.`in`.tumcampusapp.utils.observeNonNull import javax.inject.Inject @@ -93,8 +91,6 @@ class EventsListFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { } override fun onRefresh() { - val isLoggedIn = Utils.getSetting(requireContext(), CHAT_MEMBER, ChatMember::class.java) != null - viewModel.refreshEventsAndTickets(isLoggedIn) } companion object { From 16c3cbd2eb8cd4bf4a39225406d6dadd4970489d Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:51:24 +0200 Subject: [PATCH 07/22] removed internals --- .../ui/ticket/TicketAmountViewHolder.kt | 6 +- .../ui/ticket/activity/BuyTicketActivity.kt | 185 ------------------ 2 files changed, 1 insertion(+), 190 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt index 7bf7ae9310..982f19a775 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt @@ -89,11 +89,7 @@ class TicketAmountViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) } private fun notifyActivity() { - if (itemView.context is SelectTicketInterface) { - (itemView.context as SelectTicketInterface).ticketAmountUpdated(ticketTypePos, ticketAmount) - } else { - Utils.log("The context is not a SelectTicketInterface") - } + Utils.log("The context is not a SelectTicketInterface") } private fun updateButtonState() { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt index 7b95929085..32609ed63e 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt @@ -1,32 +1,8 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.activity -import android.os.Bundle -import android.transition.TransitionManager -import androidx.core.view.isVisible -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.api.app.TUMCabeClient -import de.tum.`in`.tumcampusapp.api.app.model.TUMCabeVerification import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity -import de.tum.`in`.tumcampusapp.component.other.generic.adapter.EqualSpacingItemDecoration import de.tum.`in`.tumcampusapp.component.ui.ticket.TicketAmountViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.TicketAmountAdapter -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType -import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketReservation -import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketReservationResponse -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsLocalRepository -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsRemoteRepository -import de.tum.`in`.tumcampusapp.databinding.ActivityBuyTicketBinding -import de.tum.`in`.tumcampusapp.utils.Const -import de.tum.`in`.tumcampusapp.utils.ThemedAlertDialogBuilder -import de.tum.`in`.tumcampusapp.utils.Utils -import io.reactivex.disposables.CompositeDisposable -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import javax.inject.Inject -import kotlin.math.roundToInt /** * This activity shows an overview of the available tickets and a selection of all ticket type. @@ -34,167 +10,6 @@ import kotlin.math.roundToInt */ class BuyTicketActivity : BaseActivity(R.layout.activity_buy_ticket), TicketAmountViewHolder.SelectTicketInterface { - private var eventId: Int = 0 - - private var ticketTypes: List? = null - private var currentTicketAmounts: IntArray? = null - - @Inject - internal lateinit var ticketsRemoteRepo: TicketsRemoteRepository - - @Inject - internal lateinit var eventsLocalRepo: EventsLocalRepository - - private val compositeDisposable = CompositeDisposable() - - private val totalPrice: Int - get() { - currentTicketAmounts?.let { - val types = ticketTypes ?: arrayListOf() - return it.zip(types).fold(0) { acc, amount -> acc + amount.first * amount.second.price } - } ?: return 0 - } - - private val totalTickets: Int - get() { - if (currentTicketAmounts == null) { - Utils.log("currentTicketAmounts not initialized") - return 0 - } - return currentTicketAmounts?.sum() ?: 0 - } - - private val ticketTypeIds: Array - get() = ticketTypes?.map { it.id }?.toTypedArray() ?: emptyArray() - - private lateinit var binding: ActivityBuyTicketBinding - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - binding = ActivityBuyTicketBinding.inflate(layoutInflater) - setContentView(binding.root) - - eventId = intent.getIntExtra(Const.KEY_EVENT_ID, 0) - - binding.totalPriceTextView.text = Utils.formatPrice(0) - } - - private fun setupUi() { - initEventTextViews() - initTicketAmount() - - binding.loadingOverlayBinding.loadingLayout.isVisible = false - binding.paymentButton.setOnClickListener { reserveTicket() } - } - - private fun initTicketAmount() { - val ticketAmounts = findViewById(R.id.ticketAmountsRecyclerView) - ticketAmounts.layoutManager = LinearLayoutManager(this) - ticketAmounts.setHasFixedSize(true) - ticketAmounts.adapter = TicketAmountAdapter(ticketTypes ?: emptyList()) - ticketAmounts.isNestedScrollingEnabled = false - val spacing = resources.getDimension(R.dimen.material_small_padding).roundToInt() - ticketAmounts.addItemDecoration(EqualSpacingItemDecoration(spacing)) - } - override fun ticketAmountUpdated(ticketTypeId: Int, amount: Int) { - currentTicketAmounts?.set(ticketTypeId, amount) - binding.totalPriceTextView.text = Utils.formatPrice(totalPrice) - } - - private fun showError(title: Int, message: Int) { - ThemedAlertDialogBuilder(this) - .setTitle(title) - .setMessage(message) - .setNeutralButton(R.string.ok, null) - .show() - } - - private fun initEventTextViews() { - val event = eventsLocalRepo.getEventById(eventId) - event?.let { - binding.eventName.text = it.title - binding.buyEventLocation.text = it.locality - binding.eventDate.text = it.getFormattedStartDateTime(this) - } - } - - private fun reserveTicket() { - if (totalTickets == 0) { - showError(R.string.error_no_ticket_selected, R.string.error_message_select_at_least_one_ticket) - return - } - - // don't allow user to click anything - showLoadingLayout(true) - - val reservation = TicketReservation(ticketTypeIds, currentTicketAmounts?.toTypedArray() ?: emptyArray()) - val verification = TUMCabeVerification.create(this, reservation) - if (verification == null) { - handleTicketReservationFailure(R.string.internal_error) - return - } - - TUMCabeClient - .getInstance(this) - .reserveTicket( - verification, - object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - // ResponseBody can be null if the user has already bought a ticket - // but has not fetched it from the server yet - val reservationResponse = response.body() - if (response.isSuccessful && reservationResponse != null && reservationResponse.error == null) { - handleTicketReservationSuccess(reservationResponse) - } else { - if (reservationResponse == null || !response.isSuccessful) { - handleTicketNotReserved() - } else { - handleTicketReservationFailure(R.string.event_imminent_error) - finish() - } - } - } - - override fun onFailure(call: Call, t: Throwable) { - Utils.log(t) - handleTicketReservationFailure(R.string.error_something_wrong) - } - } - ) - } - - private fun handleTicketReservationSuccess(response: TicketReservationResponse) { - showLoadingLayout(false) - } - - private fun handleTicketNotReserved() { - ThemedAlertDialogBuilder(this) - .setTitle(getString(R.string.error)) - .setMessage(getString(R.string.ticket_not_fetched)) - .setPositiveButton(R.string.ok) { _, _ -> showLoadingLayout(false) } - .show() - } - - private fun handleTicketReservationFailure(messageResId: Int) { - showLoadingLayout(false) - Utils.showToast(this, messageResId) - } - - private fun showLoadingLayout(show: Boolean) { - with(binding) { - loadingOverlayBinding.loadingLayout.isVisible = show - TransitionManager.beginDelayedTransition(loadingOverlayBinding.loadingLayout) - paymentButton.isEnabled = show.not() - } - } - - override fun onDestroy() { - compositeDisposable.dispose() - super.onDestroy() } } From 3ed2268450961abab35cb6b3ca1ca32be7c15636 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 15:53:34 +0200 Subject: [PATCH 08/22] removed internals --- .../ui/ticket/activity/ShowTicketActivity.kt | 154 +----------------- .../repository/EventsLocalRepository.kt | 4 - 2 files changed, 1 insertion(+), 157 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt index dadbd699df..3538220ea2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt @@ -1,158 +1,6 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.activity -import android.content.Intent -import android.net.Uri -import android.os.Bundle -import android.view.View -import android.view.WindowManager -import android.widget.TextView -import androidx.recyclerview.widget.LinearLayoutManager -import com.google.zxing.BarcodeFormat -import com.google.zxing.MultiFormatWriter -import com.google.zxing.WriterException -import com.journeyapps.barcodescanner.BarcodeEncoder import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity -import de.tum.`in`.tumcampusapp.component.other.generic.adapter.EqualSpacingItemDecoration -import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.BoughtTicketAdapter -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsLocalRepository -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsRemoteRepository -import de.tum.`in`.tumcampusapp.databinding.ActivityShowTicketBinding -import de.tum.`in`.tumcampusapp.utils.Const -import de.tum.`in`.tumcampusapp.utils.Utils -import io.reactivex.disposables.CompositeDisposable -import javax.inject.Inject -import kotlin.math.roundToInt -class ShowTicketActivity : BaseActivity(R.layout.activity_show_ticket) { - - private lateinit var ticketInfoList: List - private lateinit var event: Event - - @Inject - internal lateinit var eventsLocalRepo: EventsLocalRepository - - @Inject - internal lateinit var ticketsRemoteRepo: TicketsRemoteRepository - - @Inject - internal lateinit var ticketsLocalRepo: TicketsLocalRepository - - private val compositeDisposable = CompositeDisposable() - - private val redemptionState: String - get() { - - val redemptions = ticketInfoList.mapNotNull { it.tickets?.first()?.redemption } - val lastRedemption = redemptions.maxOrNull() - - val formattedDate = lastRedemption?.let { - Ticket.getFormattedRedemptionDate(this, it) - } ?: "" - - return when { - redemptions.isEmpty() -> getString(R.string.not_redeemed_yet) - redemptions.size < ticketInfoList.size -> { - val redeemed = redemptions.size - val all = ticketInfoList.size - getString(R.string.partially_redeemed, redeemed, all, formattedDate) - } - else -> getString(R.string.redeemed_at, formattedDate) - } - } - - private lateinit var binding: ActivityShowTicketBinding - - public override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - binding = ActivityShowTicketBinding.inflate(layoutInflater) - setContentView(binding.root) - - val eventId = intent.getIntExtra(Const.KEY_EVENT_ID, 0) - - initViews() - loadTicketData(eventId) - setViewData() - - showQRCode() - setWindowBrightnessToFull() - } - - private fun showQRCode() { - val qrCodeContent = ticketInfoList[0].tickets?.get(0)?.code ?: "" - Utils.log(qrCodeContent) - createQRCode(qrCodeContent) - } - - private fun initViews() { - binding.ticketList.layoutManager = LinearLayoutManager(this) - - with(binding) { - ticketList.setHasFixedSize(true) - ticketList.isNestedScrollingEnabled = false - - val spacing = resources.getDimension(R.dimen.material_tiny_padding).roundToInt() - ticketList.addItemDecoration(EqualSpacingItemDecoration(spacing)) - - swipeRefreshLayout.setColorSchemeResources( - R.color.color_primary, - R.color.tum_A100, - R.color.tum_A200 - ) - } - } - - private fun loadTicketData(eventId: Int) { - ticketInfoList = ticketsLocalRepo.getTicketsByEventId(eventId) - val eventForId = eventsLocalRepo.getEventById(eventId) - if (eventForId == null) { - finish() - return - } else { - event = eventForId - } - } - - private fun setViewData() { - binding.eventTitle.text = event.title - binding.eventDateTime.text = event.getFormattedStartDateTime(this) - binding.redemptionStateTextView.text = redemptionState - binding.eventLocation.text = event.locality - binding.eventLocation.setOnClickListener { this.showMap(it) } - - binding.ticketList.adapter = BoughtTicketAdapter(ticketInfoList) - } - - private fun showMap(view: View) { - val url = "http://maps.google.co.in/maps?q=" + (view as TextView).text - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) - startActivity(intent) - } - - private fun setWindowBrightnessToFull() { - window.attributes.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL - } - - private fun createQRCode(text: String) { - val multiFormatWriter = MultiFormatWriter() - try { - val bitMatrix = multiFormatWriter.encode(text, BarcodeFormat.QR_CODE, 200, 200) - val bitmap = BarcodeEncoder().createBitmap(bitMatrix) - binding.qrCode.setImageBitmap(bitmap) - } catch (e: WriterException) { - Utils.log(e) - Utils.showToast(this, R.string.error_something_wrong) - finish() - } - } - - override fun onDestroy() { - compositeDisposable.dispose() - super.onDestroy() - } -} +class ShowTicketActivity : BaseActivity(R.layout.activity_show_ticket) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt index 732c19f36b..9be66a410b 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt @@ -9,10 +9,6 @@ class EventsLocalRepository @Inject constructor( private val database: TcaDb ) { - fun storeEvents(events: List) { - database.eventDao().insert(events) - } - fun getEvents(): Observable> = database.eventDao().allFutureEvents fun getBookedEvents(): Observable> = database.eventDao().allBookedEvents From 41fd4a85e20741185692536643af693bbbc61fb3 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 16:13:59 +0200 Subject: [PATCH 09/22] removed internals --- .../component/ui/ticket/EventDao.kt | 3 -- .../ticket/fragment/EventDetailsFragment.kt | 1 - .../ticket/fragment/EventDetailsViewModel.kt | 44 +------------------ .../repository/EventsLocalRepository.kt | 23 ---------- .../ui/tufilm/KinoDetailsViewModel.kt | 35 +-------------- 5 files changed, 3 insertions(+), 103 deletions(-) delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDao.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDao.kt index 39681c3f8a..3ae6303ade 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDao.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventDao.kt @@ -32,9 +32,6 @@ interface EventDao { ) val nextEventWithoutMovie: Event - @Query("SELECT * FROM events where id = :id") - fun getEventById(id: Int): Event? - @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(events: List) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt index 753ee9bace..e9225e375c 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt @@ -44,7 +44,6 @@ class EventDetailsFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { } override fun onRefresh() { - viewModel.fetchTicketCount() } companion object { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt index 543c4ee988..0ea163899e 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt @@ -1,49 +1,9 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.fragment -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import de.tum.`in`.tumcampusapp.component.ui.ticket.di.EventId -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketStatus -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsRemoteRepository -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository -import de.tum.`in`.tumcampusapp.utils.Utils -import de.tum.`in`.tumcampusapp.utils.plusAssign -import io.reactivex.disposables.CompositeDisposable -import io.reactivex.schedulers.Schedulers import javax.inject.Inject class EventDetailsViewModel @Inject constructor( - @EventId val eventId: Int, - private val eventsRemoteRepository: EventsRemoteRepository, - private val ticketsLocalRepository: TicketsLocalRepository -) : ViewModel() { - - private val compositeDisposable = CompositeDisposable() - - private val _aggregatedTicketStatus = MutableLiveData() - val aggregatedTicketStatus: LiveData = _aggregatedTicketStatus - - init { - fetchTicketCount() - } - - fun fetchTicketCount() { - compositeDisposable += eventsRemoteRepository.fetchTicketStats(eventId) - .subscribeOn(Schedulers.io()) - .doOnError(Utils::log) - .subscribe(_aggregatedTicketStatus::postValue) { - _aggregatedTicketStatus.postValue(null) - } - } - - fun isEventBooked(event: Event): Boolean = ticketsLocalRepository.getTicketCount(event) > 0 - - fun getBookedTicketCount(event: Event): Int = ticketsLocalRepository.getTicketCount(event) - - override fun onCleared() { - super.onCleared() - compositeDisposable.dispose() - } -} + @EventId val eventId: Int +) : ViewModel() diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt deleted file mode 100644 index 9be66a410b..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsLocalRepository.kt +++ /dev/null @@ -1,23 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.repository - -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.database.TcaDb -import io.reactivex.Observable -import javax.inject.Inject - -class EventsLocalRepository @Inject constructor( - private val database: TcaDb -) { - - fun getEvents(): Observable> = database.eventDao().allFutureEvents - - fun getBookedEvents(): Observable> = database.eventDao().allBookedEvents - - fun getEventById(id: Int): Event? = database.eventDao().getEventById(id) - - fun getNextEventWithoutMovie(): Event = database.eventDao().nextEventWithoutMovie - - fun removePastEventsWithoutTicket() { - database.eventDao().removePastEventsWithoutTicket() - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsViewModel.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsViewModel.kt index 616e3ba911..8233764f2b 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsViewModel.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsViewModel.kt @@ -4,20 +4,11 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketStatus -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsRemoteRepository import de.tum.`in`.tumcampusapp.component.ui.tufilm.model.Kino -import de.tum.`in`.tumcampusapp.component.ui.tufilm.repository.KinoLocalRepository -import de.tum.`in`.tumcampusapp.utils.Utils -import de.tum.`in`.tumcampusapp.utils.plusAssign import io.reactivex.disposables.CompositeDisposable -import io.reactivex.schedulers.Schedulers import javax.inject.Inject -class KinoDetailsViewModel @Inject constructor( - private val localRepository: KinoLocalRepository, - private val eventsRemoteRepository: EventsRemoteRepository -) : ViewModel() { +class KinoDetailsViewModel @Inject constructor() : ViewModel() { private val compositeDisposable = CompositeDisposable() @@ -27,30 +18,6 @@ class KinoDetailsViewModel @Inject constructor( private val _event = MutableLiveData() val event: LiveData = _event - private val _aggregatedTicketStatus = MutableLiveData() - val aggregatedTicketStatus: LiveData = _aggregatedTicketStatus - - fun fetchTicketCount(eventId: Int) { - compositeDisposable += eventsRemoteRepository.fetchTicketStats(eventId) - .subscribeOn(Schedulers.io()) - .doOnError(Utils::log) - .subscribe(_aggregatedTicketStatus::postValue) { - _aggregatedTicketStatus.postValue(null) - } - } - - fun fetchKinoByPosition(position: Int) { - compositeDisposable += localRepository.getKinoByPosition(position) - .subscribeOn(Schedulers.io()) - .subscribe(_kino::postValue) - } - - fun fetchEventByMovieId(movieId: String) { - compositeDisposable += localRepository.getEventByMovieId(movieId) - .subscribeOn(Schedulers.io()) - .subscribe(_event::postValue) - } - override fun onCleared() { super.onCleared() compositeDisposable.dispose() From 9bd86463531e903deed5cf2c77521d3aad363f2e Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 16:21:33 +0200 Subject: [PATCH 10/22] removed internals --- .../in/tumcampusapp/api/app/TUMCabeClient.java | 6 ------ .../component/ui/ticket/TicketDao.kt | 3 --- .../ui/ticket/adapter/EventsAdapter.kt | 8 +------- .../ticket/repository/EventsRemoteRepository.kt | 15 +-------------- .../ticket/repository/TicketsLocalRepository.kt | 14 +------------- .../repository/TicketsRemoteRepository.kt | 4 +--- .../component/ui/tufilm/KinoDetailsFragment.kt | 17 ----------------- .../tumcampusapp/service/di/DownloadModule.kt | 5 +---- 8 files changed, 5 insertions(+), 67 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java index 7eb3bea3ef..8b991e8a82 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java @@ -237,12 +237,6 @@ public void reserveTicket(TUMCabeVerification verification, service.reserveTicket(verification).enqueue(cb); } - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - public Single> fetchTicketStats(int event) { - return service.getTicketStats(event); - } - public List fetchOpeningHours(String language) throws IOException { return service.getOpeningHours(language) .execute() diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt index 91405fe451..11108c348d 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt @@ -26,9 +26,6 @@ interface TicketDao { ) fun getByEventId(eventId: Int): List - @Query("SELECT count(*) FROM tickets WHERE event_id =:eventId") - fun getTicketCountForEvent(eventId: Int): Int - @Query("DELETE FROM tickets") fun flush() } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt index 42e926bc99..4f66664f56 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt @@ -23,8 +23,6 @@ import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.ShowTicketActivity import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventBetaInfo import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventItem -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository -import de.tum.`in`.tumcampusapp.database.TcaDb import de.tum.`in`.tumcampusapp.utils.Const import de.tum.`in`.tumcampusapp.utils.Utils import java.util.* @@ -32,10 +30,7 @@ import java.util.regex.Pattern class EventsAdapter(private val mContext: Context) : RecyclerView.Adapter() { - private val ticketsLocalRepo: TicketsLocalRepository = TicketsLocalRepository(TcaDb.getInstance(mContext)) - private var events: List = ArrayList() - private val betaInfo = EventBetaInfo() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardViewHolder { if (viewType == CARD_INFO) { @@ -75,8 +70,7 @@ class EventsAdapter(private val mContext: Context) : RecyclerView.Adapter { - return tumCabeClient.fetchTicketStats(eventId) - .map { it.reduceRight { s, a -> TicketStatus(-1, a.contingent + s.contingent, a.sold + s.sold) } } - } -} +class EventsRemoteRepository diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt index 513ee6593e..179cfd6993 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt @@ -1,25 +1,13 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.repository -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo import de.tum.`in`.tumcampusapp.database.TcaDb -import javax.inject.Inject -class TicketsLocalRepository @Inject constructor( +class TicketsLocalRepository constructor( private val database: TcaDb ) { - fun storeTickets(tickets: List) { - insert(*tickets.toTypedArray()) - } fun insert(vararg tickets: Ticket) { database.ticketDao().insert(*tickets) } - - fun getTicketsByEventId(eventId: Int): List = database.ticketDao().getByEventId(eventId) - - fun getTicketCount(event: Event): Int { - return database.ticketDao().getTicketCountForEvent(event.id) - } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt index c6c9e2198e..236e63c1b7 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt @@ -1,5 +1,3 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.repository -import javax.inject.Inject - -class TicketsRemoteRepository @Inject constructor() +class TicketsRemoteRepository diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt index 5d384f7f76..ce0e1f61d7 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt @@ -1,17 +1,12 @@ package de.tum.`in`.tumcampusapp.component.ui.tufilm -import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment -import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.TicketsLocalRepository -import de.tum.`in`.tumcampusapp.databinding.FragmentKinodetailsSectionBinding import de.tum.`in`.tumcampusapp.utils.Const -import javax.inject.Inject import javax.inject.Provider /** @@ -19,20 +14,8 @@ import javax.inject.Provider */ class KinoDetailsFragment : Fragment() { - @Inject internal lateinit var viewModelProvider: Provider - @Inject - internal lateinit var ticketsLocalRepo: TicketsLocalRepository - - private lateinit var kinoViewModel: KinoDetailsViewModel - - private val binding by viewBinding(FragmentKinodetailsSectionBinding::bind) - - override fun onAttach(context: Context) { - super.onAttach(context) - } - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, diff --git a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt index c8297a86a1..a76908be51 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt @@ -18,7 +18,6 @@ import de.tum.`in`.tumcampusapp.component.ui.news.TopNewsDownloadAction import de.tum.`in`.tumcampusapp.component.ui.news.repository.TopNewsRemoteRepository import de.tum.`in`.tumcampusapp.component.ui.openinghour.LocationImportAction import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsDownloadAction -import de.tum.`in`.tumcampusapp.component.ui.ticket.repository.EventsRemoteRepository import de.tum.`in`.tumcampusapp.component.ui.tufilm.FilmDownloadAction import de.tum.`in`.tumcampusapp.component.ui.tufilm.repository.KinoRemoteRepository import de.tum.`in`.tumcampusapp.component.ui.updatenote.UpdateNoteDownloadAction @@ -55,9 +54,7 @@ object DownloadModule { @JvmStatic @Provides - fun provideEventsDownloadAction( - remoteRepository: EventsRemoteRepository - ): EventsDownloadAction = EventsDownloadAction() + fun provideEventsDownloadAction(): EventsDownloadAction = EventsDownloadAction() @JvmStatic @Provides From 89c01e149fa96dcdbb7709f37b2455e6e628b889 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 16:22:18 +0200 Subject: [PATCH 11/22] remvoed empty repos --- .../ui/ticket/repository/EventsRemoteRepository.kt | 3 --- .../ui/ticket/repository/TicketsLocalRepository.kt | 13 ------------- .../ui/ticket/repository/TicketsRemoteRepository.kt | 3 --- 3 files changed, 19 deletions(-) delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt deleted file mode 100644 index 9c48bec81f..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/EventsRemoteRepository.kt +++ /dev/null @@ -1,3 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.repository - -class EventsRemoteRepository diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt deleted file mode 100644 index 179cfd6993..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsLocalRepository.kt +++ /dev/null @@ -1,13 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.repository - -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket -import de.tum.`in`.tumcampusapp.database.TcaDb - -class TicketsLocalRepository constructor( - private val database: TcaDb -) { - - fun insert(vararg tickets: Ticket) { - database.ticketDao().insert(*tickets) - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt deleted file mode 100644 index 236e63c1b7..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/repository/TicketsRemoteRepository.kt +++ /dev/null @@ -1,3 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.repository - -class TicketsRemoteRepository From 0fb310044a4adf469947215f6acb52495fdc3afe Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 16:25:34 +0200 Subject: [PATCH 12/22] removed now unused api calls --- .../api/app/TUMCabeAPIService.java | 34 ------------------- .../tumcampusapp/api/app/TUMCabeClient.java | 33 +----------------- 2 files changed, 1 insertion(+), 66 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java index 74aaef639f..2bb52117bb 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeAPIService.java @@ -6,7 +6,6 @@ import de.tum.in.tumcampusapp.api.app.model.DeviceUploadFcmToken; import de.tum.in.tumcampusapp.api.app.model.ObfuscatedIdsUpload; import de.tum.in.tumcampusapp.api.app.model.TUMCabeStatus; -import de.tum.in.tumcampusapp.api.app.model.TUMCabeVerification; import de.tum.in.tumcampusapp.api.app.model.UploadStatus; import de.tum.in.tumcampusapp.component.tumui.feedback.model.Feedback; import de.tum.in.tumcampusapp.component.tumui.feedback.model.FeedbackResult; @@ -19,15 +18,9 @@ import de.tum.in.tumcampusapp.component.ui.news.model.NewsAlert; import de.tum.in.tumcampusapp.component.ui.openinghour.model.Location; import de.tum.in.tumcampusapp.component.ui.studyroom.model.StudyRoomGroup; -import de.tum.in.tumcampusapp.component.ui.ticket.model.Event; -import de.tum.in.tumcampusapp.component.ui.ticket.model.Ticket; -import de.tum.in.tumcampusapp.component.ui.ticket.model.TicketType; -import de.tum.in.tumcampusapp.component.ui.ticket.payload.TicketReservationResponse; -import de.tum.in.tumcampusapp.component.ui.ticket.payload.TicketStatus; import de.tum.in.tumcampusapp.component.ui.tufilm.model.Kino; import io.reactivex.Flowable; import io.reactivex.Observable; -import io.reactivex.Single; import okhttp3.MultipartBody; import retrofit2.Call; import retrofit2.http.Body; @@ -43,7 +36,6 @@ import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_CAFETERIAS; import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_CHAT_MEMBERS; import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_DEVICE; -import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_EVENTS; import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_FEEDBACK; import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_KINOS; import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_LOCATIONS; @@ -52,7 +44,6 @@ import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_NOTIFICATIONS; import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_OPENING_HOURS; import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_STUDY_ROOMS; -import static de.tum.in.tumcampusapp.api.app.TUMCabeClient.API_TICKET; public interface TUMCabeAPIService { @POST(API_CHAT_MEMBERS) @@ -112,31 +103,6 @@ public interface TUMCabeAPIService { @GET(API_STUDY_ROOMS) Call> getStudyRoomGroups(); - // TICKET SALE - - // Getting Event information - - @GET(API_EVENTS + "list") - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - Observable> getEvents(); - - - @POST(API_EVENTS + API_TICKET + "{ticketID}") - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - Call getTicket(@Path("ticketID") int ticketID, @Body TUMCabeVerification verification); - - // Ticket reservation - @POST(API_EVENTS + API_TICKET + "reserve/multiple") - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - Call reserveTicket(@Body TUMCabeVerification verification); - - @GET(API_EVENTS + API_TICKET + "status/{event}") - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - Single> getTicketStats(@Path("event") int event); // Opening Hours @GET(API_OPENING_HOURS + "{language}") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java index 8b991e8a82..e073ff7be2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java @@ -28,24 +28,14 @@ import de.tum.in.tumcampusapp.component.ui.barrierfree.model.BarrierFreeMoreInfo; import de.tum.in.tumcampusapp.component.ui.cafeteria.model.Cafeteria; import de.tum.in.tumcampusapp.component.ui.chat.model.ChatMember; -import de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage; -import de.tum.in.tumcampusapp.component.ui.chat.model.ChatRoom; -import de.tum.in.tumcampusapp.component.ui.news.model.News; import de.tum.in.tumcampusapp.component.ui.news.model.NewsAlert; -import de.tum.in.tumcampusapp.component.ui.news.model.NewsSources; import de.tum.in.tumcampusapp.component.ui.openinghour.model.Location; import de.tum.in.tumcampusapp.component.ui.studyroom.model.StudyRoomGroup; -import de.tum.in.tumcampusapp.component.ui.ticket.model.Event; -import de.tum.in.tumcampusapp.component.ui.ticket.model.Ticket; -import de.tum.in.tumcampusapp.component.ui.ticket.model.TicketType; -import de.tum.in.tumcampusapp.component.ui.ticket.payload.TicketReservationResponse; -import de.tum.in.tumcampusapp.component.ui.ticket.payload.TicketStatus; import de.tum.in.tumcampusapp.component.ui.tufilm.model.Kino; import de.tum.in.tumcampusapp.utils.Const; import de.tum.in.tumcampusapp.utils.Utils; import io.reactivex.Flowable; import io.reactivex.Observable; -import io.reactivex.Single; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.RequestBody; @@ -54,7 +44,6 @@ import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; -import retrofit2.http.Body; /** * Proxy class for Retrofit client to our API hosted @app.tum.de @@ -72,13 +61,10 @@ public final class TUMCabeClient { static final String API_CAFETERIAS = "mensen/"; static final String API_KINOS = "kino/"; static final String API_NEWS = "news/"; - static final String API_EVENTS = "event/"; - static final String API_TICKET = "ticket/"; static final String API_STUDY_ROOMS = "studyroom/list"; private static final String API_HOSTNAME = Const.API_HOSTNAME; private static final String API_BASEURL = "/Api/"; - private static final String API_CHAT = "chat/"; - static final String API_CHAT_MEMBERS = API_CHAT + "members/"; + static final String API_CHAT_MEMBERS = "chat/members/"; static final String API_OPENING_HOURS = "openingtimes/"; private static TUMCabeClient instance; @@ -220,23 +206,6 @@ public Call> getStudyRoomGroups() { return service.getStudyRoomGroups(); } - // TICKET SALE - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - public Call fetchTicket(Context context, int ticketID) throws NoPrivateKey { - TUMCabeVerification verification = getVerification(context, null); - return service.getTicket(ticketID, verification); - } - - // Ticket reservation - - @Deprecated - /// This endpoint won't be avaliable in the v2 backend - public void reserveTicket(TUMCabeVerification verification, - Callback cb) { - service.reserveTicket(verification).enqueue(cb); - } - public List fetchOpeningHours(String language) throws IOException { return service.getOpeningHours(language) .execute() From 5e559b4047e026137ebd726fa430a95b639b452d Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 17:39:42 +0200 Subject: [PATCH 13/22] removed internals --- .../ui/ticket/adapter/EventsAdapter.kt | 80 +------------------ .../ui/ticket/fragment/EventsListFragment.kt | 68 +--------------- 2 files changed, 4 insertions(+), 144 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt index 4f66664f56..1358db9292 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt @@ -1,32 +1,17 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.adapter import android.content.Context -import android.content.Intent import android.view.LayoutInflater import android.view.View -import android.view.View.GONE import android.view.ViewGroup -import android.widget.ImageView -import android.widget.ProgressBar -import android.widget.TextView -import androidx.constraintlayout.widget.Group -import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.button.MaterialButton -import com.squareup.picasso.Callback -import com.squareup.picasso.Picasso import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder import de.tum.`in`.tumcampusapp.component.ui.ticket.EventCard -import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.ShowTicketActivity import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventBetaInfo import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventItem -import de.tum.`in`.tumcampusapp.utils.Const -import de.tum.`in`.tumcampusapp.utils.Utils -import java.util.* -import java.util.regex.Pattern class EventsAdapter(private val mContext: Context) : RecyclerView.Adapter() { @@ -45,7 +30,7 @@ class EventsAdapter(private val mContext: Context) : RecyclerView.Adapter) { + fun update(_es: MutableList) { } - class EventViewHolder( - view: View, - interactionListener: CardInteractionListener?, - private val showOptionsButton: Boolean - ) : CardViewHolder(view, interactionListener) { - - private var optionsButtonGroup: Group = view.findViewById(R.id.cardMoreIconGroup) - private var progressBar: ProgressBar = view.findViewById(R.id.poster_progress_bar) - private var imageView: ImageView = view.findViewById(R.id.events_img) - private var titleTextView: TextView = view.findViewById(R.id.events_title) - private var startDateTextView: TextView = view.findViewById(R.id.events_src_date) - private var ticketButton: MaterialButton = view.findViewById(R.id.ticketButton) - - fun bind(event: Event, ticketCount: Int) { - optionsButtonGroup.isVisible = showOptionsButton - - val imageUrl = event.imageUrl - val showImage = !imageUrl.isNullOrEmpty() - if (showImage) { - Picasso.get() - .load(imageUrl) - .into( - imageView, - object : Callback { - override fun onSuccess() { - progressBar.visibility = GONE - } - - override fun onError(e: Exception) { - Utils.log(e) - progressBar.visibility = GONE - } - } - ) - } else { - progressBar.visibility = GONE - imageView.visibility = GONE - } - - titleTextView.text = TITLE_DATE.matcher(event.title).replaceAll("") - startDateTextView.text = event.getFormattedStartDateTime(itemView.context) - - ticketButton.isVisible = ticketCount != 0 - if (ticketCount == 0) { - return - } - ticketButton.text = itemView.context.resources - .getQuantityString(R.plurals.tickets, ticketCount, ticketCount) - ticketButton.setOnClickListener { - val context = itemView.context - val intent = Intent(context, ShowTicketActivity::class.java) - intent.putExtra(Const.KEY_EVENT_ID, event.id) - context.startActivity(intent) - } - } - } + class EventViewHolder(view: View, interactionListener: CardInteractionListener?) : CardViewHolder(view, interactionListener) companion object { - private val TITLE_DATE = Pattern.compile("^[0-9]+\\. [0-9]+\\. [0-9]+:[ ]*") - private const val CARD_INFO = 0 private const val CARD_HORIZONTAL = 1 private const val CARD_VERTICAL = 2 diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt index 0f2ceda0dc..86f56a20f1 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt @@ -5,41 +5,18 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProvider -import androidx.recyclerview.widget.DefaultItemAnimator -import androidx.recyclerview.widget.LinearLayoutManager import androidx.swiperefreshlayout.widget.SwipeRefreshLayout -import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.adapter.EqualSpacingItemDecoration import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsViewModel -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsViewState -import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.EventsAdapter import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventType -import de.tum.`in`.tumcampusapp.databinding.FragmentEventsListBinding -import de.tum.`in`.tumcampusapp.di.ViewModelFactory -import de.tum.`in`.tumcampusapp.utils.Utils -import de.tum.`in`.tumcampusapp.utils.observeNonNull import javax.inject.Inject import javax.inject.Provider -import kotlin.math.roundToInt class EventsListFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { - private val eventType: EventType by lazy { - arguments?.getSerializable(KEY_EVENT_TYPE) as EventType - } - @Inject lateinit var provider: Provider - private val viewModel: EventsViewModel by lazy { - val factory = ViewModelFactory(provider) - ViewModelProvider(this, factory).get(EventsViewModel::class.java) - } - - private val binding by viewBinding(FragmentEventsListBinding::bind) - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -48,50 +25,7 @@ class EventsListFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { return inflater.inflate(R.layout.fragment_events_list, container, false) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(view) { - binding.eventsRecyclerView.setHasFixedSize(true) - binding.eventsRecyclerView.layoutManager = LinearLayoutManager(context) - binding.eventsRecyclerView.itemAnimator = DefaultItemAnimator() - binding.eventsRecyclerView.adapter = EventsAdapter(context) - - val spacing = resources.getDimension(R.dimen.material_card_view_padding).roundToInt() - binding.eventsRecyclerView.addItemDecoration(EqualSpacingItemDecoration(spacing)) - - binding.eventsRefreshLayout.setOnRefreshListener(this@EventsListFragment) - binding.eventsRefreshLayout.setColorSchemeResources( - R.color.color_primary, - R.color.tum_A100, - R.color.tum_A200 - ) - - viewModel.viewState.observeNonNull(viewLifecycleOwner, this@EventsListFragment::render) - } - - private fun render(viewState: EventsViewState) { - val isEmpty = viewState.events.isEmpty() - with(binding) { - eventsRecyclerView.visibility = if (isEmpty) View.GONE else View.VISIBLE - eventPlaceholder.visibility = if (isEmpty) View.VISIBLE else View.GONE - - eventsRefreshLayout.isRefreshing = false - - if (viewState.events.isNotEmpty()) { - val adapter = eventsRecyclerView.adapter as EventsAdapter - adapter.update(viewState.events.toMutableList()) - } else { - placeholderTextView.setText(eventType.placeholderTextId) - placeholderImage.setImageResource(eventType.placeholderImageId) - } - - eventsRefreshLayout.isRefreshing = viewState.isLoading - viewState.errorResId?.let { - Utils.showToast(requireContext(), it) - } - } - } - - override fun onRefresh() { - } + override fun onRefresh() = Unit companion object { From 90c7e325c8af812e304c3bd2fbab510afcb4e4f5 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 17:41:07 +0200 Subject: [PATCH 14/22] remvoed internals --- .../ui/ticket/adapter/EventsAdapter.kt | 36 ++----------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt index 1358db9292..4cf1b40f40 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt @@ -1,6 +1,5 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.adapter -import android.content.Context import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -8,52 +7,23 @@ import androidx.recyclerview.widget.RecyclerView import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventCard -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventBetaInfo import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventItem -class EventsAdapter(private val mContext: Context) : RecyclerView.Adapter() { +class EventsAdapter : RecyclerView.Adapter() { private var events: List = ArrayList() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardViewHolder { - if (viewType == CARD_INFO) { - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.card_events_info, parent, false) - return CardViewHolder(view) - } - - val layoutRes = if (viewType == CARD_HORIZONTAL) { - R.layout.card_events_item - } else { - R.layout.card_events_item_vertical - } + val layoutRes = R.layout.card_events_item_vertical val view = LayoutInflater.from(parent.context).inflate(layoutRes, parent, false) return EventViewHolder(view, null) } override fun getItemViewType(position: Int): Int { - val item = events[position] - if (item is EventBetaInfo) { - return CARD_INFO - } - return if ((item as Event).kino == -1) { - CARD_HORIZONTAL - } else { - CARD_VERTICAL - } + return CARD_INFO } override fun onBindViewHolder(holder: CardViewHolder, position: Int) { - val eventItem = events[position] - if (eventItem is EventBetaInfo) { - return - } - val event = eventItem as Event - val eventCard = EventCard(mContext) - eventCard.event = event - holder.currentCard = eventCard } override fun getItemCount() = events.size From 95d2eaca88b883b25e460fbb51ec663bde80c852 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 17:43:20 +0200 Subject: [PATCH 15/22] remvoed card --- .../in/tumcampusapp/component/ui/overview/CardManager.kt | 1 - .../tumcampusapp/component/ui/overview/CardsRepository.kt | 7 +------ app/src/main/res/values/strings.xml | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardManager.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardManager.kt index 5590f68810..5cf8f9a08f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardManager.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardManager.kt @@ -31,7 +31,6 @@ object CardManager { LOGIN(R.layout.card_login_prompt, R.string.login_default_sharedpref_shown), EDUROAM_FIX(R.layout.card_eduroam_fix, R.string.eduroam_fix_default_sharedpref_shown), TOP_NEWS(R.layout.card_top_news, R.string.top_news_default_sharedpref_shown), - EVENT(R.layout.card_events_item, R.string.event_default_sharedpref_shown), UPDATE_NOTE(R.layout.card_update_note, R.string.update_note_default_sharedpref_shown) } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardsRepository.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardsRepository.kt index dd23c32120..130bfb0b55 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardsRepository.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardsRepository.kt @@ -16,7 +16,6 @@ import de.tum.`in`.tumcampusapp.component.ui.news.TopNewsCard import de.tum.`in`.tumcampusapp.component.ui.onboarding.LoginPromptCard import de.tum.`in`.tumcampusapp.component.ui.overview.card.Card import de.tum.`in`.tumcampusapp.component.ui.overview.card.ProvidesCard -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventCardsProvider import de.tum.`in`.tumcampusapp.component.ui.transportation.TransportController import de.tum.`in`.tumcampusapp.component.ui.updatenote.UpdateNoteCard import de.tum.`in`.tumcampusapp.utils.Utils @@ -25,10 +24,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import javax.inject.Inject -class CardsRepository @Inject constructor( - private val context: Context, - private val eventCardsProvider: EventCardsProvider -) { +class CardsRepository @Inject constructor(private val context: Context) { private var cards = MutableLiveData>() @@ -77,7 +73,6 @@ class CardsRepository @Inject constructor( add(CafeteriaManager(context)) add(TransportController(context)) add(NewsController(context)) - add(eventCardsProvider) } providers.forEach { provider -> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 196bce24af..4b7f9fb65e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -347,7 +347,6 @@ LoginCardShown EduroamFixCardShown TopNewsCardShown - EventCardShown UpdateNoteCardShown From 8ea8671bfc6cd78557caa6c0a3c12dde54268e18 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 17:44:42 +0200 Subject: [PATCH 16/22] remvoed internals --- .../ui/ticket/activity/EventDetailsActivity.kt | 16 +--------------- .../ui/ticket/activity/EventsActivity.kt | 15 +-------------- .../component/ui/ticket/adapter/EventsAdapter.kt | 2 -- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt index e70f52a0a2..15b0a62706 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt @@ -1,25 +1,11 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.activity -import android.os.Bundle import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity -import de.tum.`in`.tumcampusapp.component.ui.ticket.fragment.EventDetailsFragment -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.utils.Const /** * This Activity displays more information about the event * Especially the full description, link and the full dates * Navigates back to EventsActivity or opens BuyTicketActivity */ -class EventDetailsActivity : BaseActivity(R.layout.activity_event_details) { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val event = intent.getParcelableExtra(Const.KEY_EVENT) - supportFragmentManager - .beginTransaction() - .replace(R.id.fragment_container, EventDetailsFragment.newInstance(event!!)) - .commit() - } -} +class EventDetailsActivity : BaseActivity(R.layout.activity_event_details) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt index 3c398880a9..0d945b2435 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt @@ -1,19 +1,6 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.activity -import android.os.Bundle import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity -class EventsActivity : BaseActivity(R.layout.activity_events) { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - if (savedInstanceState == null) { - supportFragmentManager - .beginTransaction() - .replace(R.id.contentFrame, EventsFragment.newInstance()) - .commit() - } - } -} +class EventsActivity : BaseActivity(R.layout.activity_events) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt index 4cf1b40f40..6c58631d1f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt @@ -35,7 +35,5 @@ class EventsAdapter : RecyclerView.Adapter() { companion object { private const val CARD_INFO = 0 - private const val CARD_HORIZONTAL = 1 - private const val CARD_VERTICAL = 2 } } From 7bc178f140e5ff7b90311de3729dba63c576e8b5 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 17:47:12 +0200 Subject: [PATCH 17/22] remvoed internals --- .../activity/PaymentConfirmationActivity.kt | 59 +------------------ 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt index 1ef1a409de..7a6694137d 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt @@ -1,63 +1,6 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.activity -import android.content.Intent -import android.graphics.drawable.Animatable -import android.os.Bundle -import android.view.MenuItem import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity -import de.tum.`in`.tumcampusapp.databinding.ActivityPaymentConfirmationBinding -import de.tum.`in`.tumcampusapp.utils.Const -import java.util.* -import kotlin.concurrent.schedule -class PaymentConfirmationActivity : BaseActivity(R.layout.activity_payment_confirmation) { - - private lateinit var binding: ActivityPaymentConfirmationBinding - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - binding = ActivityPaymentConfirmationBinding.inflate(layoutInflater) - setContentView(binding.root) - - val eventId = intent.getIntExtra(Const.KEY_EVENT_ID, -1) - val ticketAmount = intent.getIntExtra(Const.KEY_TICKET_AMOUNT, 1) - if (eventId == -1) { - finish() - return - } - - binding.bodyTextView.text = resources.getQuantityString(R.plurals.tickets_saved_in_app, ticketAmount) - binding.showTicketButton.text = resources.getQuantityString(R.plurals.show_tickets, ticketAmount) - - binding.showTicketButton.setOnClickListener { - val intent = Intent(this, ShowTicketActivity::class.java) - intent.putExtra(Const.KEY_EVENT_ID, eventId) - startActivity(intent) - } - - runCheckmarkAnimation() - } - - private fun runCheckmarkAnimation() { - Timer().schedule(200) { - runOnUiThread { - val animatedCheckmark = binding.imageView.drawable as? Animatable - animatedCheckmark?.start() - } - } - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - android.R.id.home -> { - true - } - else -> super.onOptionsItemSelected(item) - } - } - - override fun onBackPressed() { - } -} +class PaymentConfirmationActivity : BaseActivity(R.layout.activity_payment_confirmation) From d1c40ff25b683781b84f4c856568d5e375dce514 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 19:09:06 +0200 Subject: [PATCH 18/22] remvoed internals --- .../component/ui/overview/CardAdapter.kt | 2 -- .../ui/ticket/adapter/BoughtTicketAdapter.kt | 23 ------------------- .../ticket/fragment/EventDetailsFragment.kt | 17 -------------- 3 files changed, 42 deletions(-) delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/BoughtTicketAdapter.kt diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardAdapter.kt index bd464da562..9a886647c0 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardAdapter.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/CardAdapter.kt @@ -13,7 +13,6 @@ import de.tum.`in`.tumcampusapp.component.ui.news.TopNewsCard import de.tum.`in`.tumcampusapp.component.ui.onboarding.LoginPromptCard import de.tum.`in`.tumcampusapp.component.ui.overview.card.Card import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventCard import de.tum.`in`.tumcampusapp.component.ui.transportation.MVVCard import de.tum.`in`.tumcampusapp.component.ui.updatenote.UpdateNoteCard import java.util.* @@ -39,7 +38,6 @@ class CardAdapter(private val interactionListener: CardInteractionListener) : Re CardManager.CardTypes.SUPPORT.id -> return SupportCard.inflateViewHolder(viewGroup, interactionListener) CardManager.CardTypes.LOGIN.id -> return LoginPromptCard.inflateViewHolder(viewGroup, interactionListener) CardManager.CardTypes.TOP_NEWS.id -> return TopNewsCard.inflateViewHolder(viewGroup, interactionListener) - CardManager.CardTypes.EVENT.id -> return EventCard.inflateViewHolder(viewGroup, interactionListener) CardManager.CardTypes.UPDATE_NOTE.id -> return UpdateNoteCard.inflateViewHolder(viewGroup, interactionListener) else -> throw UnsupportedOperationException() } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/BoughtTicketAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/BoughtTicketAdapter.kt deleted file mode 100644 index be2b8e04d5..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/BoughtTicketAdapter.kt +++ /dev/null @@ -1,23 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.adapter - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.ticket.BoughtTicketViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo - -class BoughtTicketAdapter(private val ticketInfos: List) : RecyclerView.Adapter() { - - override fun onCreateViewHolder(parent: ViewGroup, i: Int): BoughtTicketViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.bought_ticket_row, parent, false) - return BoughtTicketViewHolder(view) - } - - override fun onBindViewHolder(viewHolder: BoughtTicketViewHolder, i: Int) { - viewHolder.bind(ticketInfos[i]) - } - - override fun getItemCount() = ticketInfos.size -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt index e9225e375c..9b774ed73e 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt @@ -5,33 +5,16 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProvider import androidx.swiperefreshlayout.widget.SwipeRefreshLayout -import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.databinding.FragmentEventDetailsBinding -import de.tum.`in`.tumcampusapp.di.ViewModelFactory import de.tum.`in`.tumcampusapp.utils.Const -import javax.inject.Inject -import javax.inject.Provider /** * Fragment for displaying information about an [Event]. Manages content that's shown in the * PagerAdapter. */ class EventDetailsFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { - - private val viewModel: EventDetailsViewModel by lazy { - val factory = ViewModelFactory(viewModelProviders) - ViewModelProvider(this, factory).get(EventDetailsViewModel::class.java) - } - - @Inject - lateinit var viewModelProviders: Provider - - private val binding by viewBinding(FragmentEventDetailsBinding::bind) - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, From eab215a1856cce1422a4b8889fb3721b8b31daa1 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 19:46:58 +0200 Subject: [PATCH 19/22] removed the rest of the code which is not the db --- .../ui/ticket/BoughtTicketViewHolder.kt | 11 --- .../component/ui/ticket/EventCard.kt | 52 ---------- .../component/ui/ticket/EventCardsProvider.kt | 18 ---- .../component/ui/ticket/EventHelper.kt | 23 ----- .../ui/ticket/EventsDownloadAction.kt | 11 --- .../component/ui/ticket/EventsViewModel.kt | 45 --------- .../component/ui/ticket/EventsViewState.kt | 31 ------ .../ui/ticket/TicketAmountViewHolder.kt | 99 ------------------- .../component/ui/ticket/TicketDao.kt | 14 --- .../component/ui/ticket/TicketTypeDao.kt | 5 - .../ui/ticket/activity/BuyTicketActivity.kt | 15 --- .../ticket/activity/EventDetailsActivity.kt | 11 --- .../ui/ticket/activity/EventsActivity.kt | 6 -- .../ui/ticket/activity/EventsFragment.kt | 95 ------------------ .../activity/PaymentConfirmationActivity.kt | 6 -- .../ui/ticket/activity/ShowTicketActivity.kt | 6 -- .../ui/ticket/adapter/EventsAdapter.kt | 39 -------- .../ui/ticket/adapter/TicketAmountAdapter.kt | 22 ----- .../component/ui/ticket/di/EventId.kt | 6 -- .../ticket/fragment/EventDetailsFragment.kt | 43 -------- .../ticket/fragment/EventDetailsViewModel.kt | 9 -- .../ui/ticket/fragment/EventsListFragment.kt | 43 -------- .../component/ui/ticket/model/Event.kt | 6 -- .../ui/ticket/model/EventBetaInfo.kt | 16 --- .../component/ui/ticket/model/EventType.kt | 8 -- .../component/ui/ticket/model/Payment.kt | 4 - .../component/ui/ticket/model/TicketInfo.kt | 13 --- .../component/ui/ticket/model/TicketType.kt | 3 - .../ui/ticket/payload/EphimeralKey.kt | 8 -- .../ui/ticket/payload/TicketReservation.kt | 9 -- .../payload/TicketReservationResponse.kt | 9 -- .../ui/ticket/payload/TicketStatus.kt | 16 --- .../service/di/DownloadComponent.kt | 2 - .../tumcampusapp/service/di/DownloadModule.kt | 5 - 34 files changed, 709 deletions(-) delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewState.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsFragment.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/TicketAmountAdapter.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/di/EventId.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventBetaInfo.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventType.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketInfo.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/EphimeralKey.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservation.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservationResponse.kt delete mode 100644 app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketStatus.kt diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt deleted file mode 100644 index fd35f3bdb6..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt +++ /dev/null @@ -1,11 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import android.view.View -import androidx.recyclerview.widget.RecyclerView -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo - -class BoughtTicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - - fun bind(ticketInfo: TicketInfo) { - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt deleted file mode 100644 index 392f443c23..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCard.kt +++ /dev/null @@ -1,52 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import android.content.Context -import android.content.SharedPreferences -import android.os.Bundle -import android.view.LayoutInflater -import android.view.ViewGroup -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.navigation.NavDestination -import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener -import de.tum.`in`.tumcampusapp.component.ui.overview.CardManager -import de.tum.`in`.tumcampusapp.component.ui.overview.card.Card -import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.adapter.EventsAdapter -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.component.ui.tufilm.KinoActivity -import de.tum.`in`.tumcampusapp.utils.Const - -class EventCard(context: Context) : Card(CardManager.CardTypes.EVENT, context) { - - var event: Event? = null - - // TODO(thellmund) Inject this - private val eventCardsProvider = EventCardsProvider() - - override fun getNavigationDestination(): NavDestination { - val args = Bundle().apply { putInt(Const.KINO_ID, 1) } - return NavDestination.Activity(KinoActivity::class.java, args) - } - - override fun shouldShow(prefs: SharedPreferences): Boolean { - return event?.dismissed == 0 - } - - override fun discard(editor: SharedPreferences.Editor) { - event?.let { - eventCardsProvider.setDismissed(it.id) - } - } - - companion object { - - @JvmStatic - fun inflateViewHolder( - parent: ViewGroup, - interactionListener: CardInteractionListener - ): CardViewHolder { - val card = LayoutInflater.from(parent.context).inflate(R.layout.card_events_item, parent, false) - return EventsAdapter.EventViewHolder(card, interactionListener, true) - } - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt deleted file mode 100644 index 83ba4558b9..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventCardsProvider.kt +++ /dev/null @@ -1,18 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import de.tum.`in`.tumcampusapp.api.tumonline.CacheControl -import de.tum.`in`.tumcampusapp.component.ui.overview.card.Card -import de.tum.`in`.tumcampusapp.component.ui.overview.card.ProvidesCard -import java.util.* -import javax.inject.Inject - -class EventCardsProvider @Inject -constructor() : ProvidesCard { - - fun setDismissed(id: Int) { - } - - override fun getCards(cacheControl: CacheControl): List { - return ArrayList() - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt deleted file mode 100644 index 5dec8eb21d..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventHelper.kt +++ /dev/null @@ -1,23 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import android.view.View -import android.widget.TextView -import de.tum.`in`.tumcampusapp.component.ui.ticket.payload.TicketStatus - -/** - * Logic associated with the buy button that is needed in the EventDetailsFragment - * and the KinoDetailsFragment. - */ -class EventHelper { - companion object { - fun showRemainingTickets( - status: TicketStatus?, - isEventBooked: Boolean, - isEventImminent: Boolean, - buyTicketButton: View, - remainingTicketsContainer: View, - remainingTicketsTextView: TextView, - noTicketsMessage: String - ) { } - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt deleted file mode 100644 index e2777e6b0a..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsDownloadAction.kt +++ /dev/null @@ -1,11 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import de.tum.`in`.tumcampusapp.api.tumonline.CacheControl -import de.tum.`in`.tumcampusapp.service.DownloadWorker -import javax.inject.Inject - -class EventsDownloadAction @Inject constructor() : DownloadWorker.Action { - - override fun execute(cacheBehaviour: CacheControl) { - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt deleted file mode 100644 index b4b0bcc990..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewModel.kt +++ /dev/null @@ -1,45 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.utils.plusAssign -import io.reactivex.disposables.CompositeDisposable -import javax.inject.Inject - -sealed class Action { - data class Refresh(val isLoggedIn: Boolean) : Action() -} - -sealed class Result { - object ShowLoading : Result() - data class EventsLoaded(val events: List) : Result() - object ShowError : Result() - object HideError : Result() - object None : Result() -} - -class EventsViewModel @Inject constructor() : ViewModel() { - - private val compositeDisposable = CompositeDisposable() - - private val _viewState = MutableLiveData() - val viewState: LiveData = _viewState - - fun refreshEventsAndTickets() { - } - - private fun render(viewState: EventsViewState) { - _viewState.postValue(viewState) - } - - override fun onCleared() { - super.onCleared() - compositeDisposable.dispose() - } - - companion object { - private const val ERROR_DURATION: Long = 4 - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewState.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewState.kt deleted file mode 100644 index d14f0e2843..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/EventsViewState.kt +++ /dev/null @@ -1,31 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event - -data class EventsViewState( - val events: List = emptyList(), - val errorResId: Int? = null, - val isLoading: Boolean = false -) { - - fun toLoading(): EventsViewState { - return copy(isLoading = true) - } - - fun toEventsLoaded(events: List): EventsViewState { - return copy(events = events, isLoading = false) - } - - fun toError(): EventsViewState { - return copy(errorResId = R.string.error_something_wrong, isLoading = false) - } - - fun toNoError(): EventsViewState { - return copy(errorResId = null) - } - - companion object { - fun initial() = EventsViewState(isLoading = true) - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt deleted file mode 100644 index 982f19a775..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt +++ /dev/null @@ -1,99 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket - -import android.content.res.Resources -import android.view.View -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.button.MaterialButton -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType -import de.tum.`in`.tumcampusapp.utils.Utils - -class TicketAmountViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - - interface SelectTicketInterface { - fun ticketAmountUpdated(ticketTypeId: Int, amount: Int) - } - - private val minusButton: MaterialButton by lazy { itemView.findViewById(R.id.ticket_amount_minus) } - private val plusButton: MaterialButton by lazy { itemView.findViewById(R.id.ticket_amount_plus) } - private val currentAmount: TextView by lazy { itemView.findViewById(R.id.current_ticket_amount) } - private val ticketTypeName: TextView by lazy { itemView.findViewById(R.id.ticket_type_name) } - private val ticketPrice: TextView by lazy { itemView.findViewById(R.id.price_per_ticket) } - - private var ticketAmount = 1 - private var ticketType = TicketType() - private var ticketTypePos = 0 - private var remainingTickets = 0 - private var minAmount = 1 - private var maxAmount = 1 - - fun bindToTicketType(ticketType: TicketType, position: Int) { - this.ticketType = ticketType - ticketTypePos = position - - minAmount = ticketType.paymentInfo.minTickets - maxAmount = ticketType.paymentInfo.maxTickets - - if (position == 0) { - ticketAmount = minAmount - notifyActivity() - } else { - ticketAmount = 0 - } - - // init text views - ticketTypeName.text = ticketType.description - ticketPrice.text = itemView.resources.getString(R.string.price_per_ticket, Utils.formatPrice(ticketType.price)) - currentAmount.text = ticketAmount.toString() - // init buttons - plusButton.setOnClickListener { updateTicketAmount(true) } - minusButton.setOnClickListener { updateTicketAmount(false) } - - // handle how many tickets are left - remainingTickets = ticketType.contingent - ticketType.sold - maxAmount = Math.min(maxAmount, remainingTickets) - if (remainingTickets < minAmount) { - ticketAmount = 0 - currentAmount.text = ticketAmount.toString() - plusButton.isEnabled = false - minusButton.isEnabled = false - ticketTypeName.setTextColor(Resources.getSystem().getColor(R.color.text_light_gray, null)) - } - updateButtonState() - } - - /** - * Updates the current ticket amount when the plus or minus button is clicked, - * makes sure the min and max amount of tickets is adhered to (either 0 tickets or minAmount of tickets, nothing in between) - * and the user doesn't select more tickets than are available - */ - private fun updateTicketAmount(increase: Boolean) { - if (increase) { - if (ticketAmount == 0) { - ticketAmount = minAmount - } else { - ticketAmount++ - } - } else { - if (ticketAmount == minAmount) { - ticketAmount = 0 - } else { - ticketAmount-- - } - } - currentAmount.text = ticketAmount.toString() - updateButtonState() - - notifyActivity() - } - - private fun notifyActivity() { - Utils.log("The context is not a SelectTicketInterface") - } - - private fun updateButtonState() { - plusButton.isEnabled = ticketAmount != maxAmount - minusButton.isEnabled = ticketAmount != 0 - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt index 11108c348d..04e94b3677 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketDao.kt @@ -4,10 +4,7 @@ import androidx.room.Dao import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query -import androidx.room.RoomWarnings -import androidx.room.Transaction import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Ticket -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo @Dao interface TicketDao { @@ -15,17 +12,6 @@ interface TicketDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(vararg ticket: Ticket) - // TODO Room behaviour changed, complaining about this query - @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) - @Transaction - @Query( - "SELECT count(*) as count, t.*, tt.* FROM tickets t, ticket_types tt " + - "WHERE t.event_id = :eventId " + - "AND t.ticket_type_id = tt.id " + - "GROUP BY t.ticket_type_id" - ) - fun getByEventId(eventId: Int): List - @Query("DELETE FROM tickets") fun flush() } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketTypeDao.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketTypeDao.kt index b244b98ead..0cc9332fe6 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketTypeDao.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketTypeDao.kt @@ -4,7 +4,6 @@ import androidx.room.Dao import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query -import androidx.room.RoomWarnings import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType @Dao @@ -16,10 +15,6 @@ interface TicketTypeDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(ticketTypes: List) - @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) - @Query("SELECT * FROM ticket_types tt, tickets t WHERE tt.id = t.ticket_type_id AND t.event_id = :eventId") - fun getByEventId(eventId: Int): List - @Query("DELETE FROM ticket_types") fun flush() } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt deleted file mode 100644 index 32609ed63e..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/BuyTicketActivity.kt +++ /dev/null @@ -1,15 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.activity - -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity -import de.tum.`in`.tumcampusapp.component.ui.ticket.TicketAmountViewHolder - -/** - * This activity shows an overview of the available tickets and a selection of all ticket type. - * It directs the user to the PaymentConfirmationActivity or back to EventDetailsActivity - */ -class BuyTicketActivity : BaseActivity(R.layout.activity_buy_ticket), TicketAmountViewHolder.SelectTicketInterface { - - override fun ticketAmountUpdated(ticketTypeId: Int, amount: Int) { - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt deleted file mode 100644 index 15b0a62706..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventDetailsActivity.kt +++ /dev/null @@ -1,11 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.activity - -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity - -/** - * This Activity displays more information about the event - * Especially the full description, link and the full dates - * Navigates back to EventsActivity or opens BuyTicketActivity - */ -class EventDetailsActivity : BaseActivity(R.layout.activity_event_details) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt deleted file mode 100644 index 0d945b2435..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsActivity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.activity - -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity - -class EventsActivity : BaseActivity(R.layout.activity_events) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsFragment.kt deleted file mode 100644 index feb95735c5..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/EventsFragment.kt +++ /dev/null @@ -1,95 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.activity - -import android.content.Context -import android.os.Bundle -import android.view.View -import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentManager -import androidx.fragment.app.FragmentPagerAdapter -import androidx.viewpager.widget.ViewPager -import com.google.android.material.tabs.TabLayout -import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.fragment.FragmentForDownloadingExternal -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsDownloadAction -import de.tum.`in`.tumcampusapp.component.ui.ticket.fragment.EventsListFragment -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventType -import de.tum.`in`.tumcampusapp.databinding.FragmentEventsBinding -import de.tum.`in`.tumcampusapp.di.injector -import de.tum.`in`.tumcampusapp.service.DownloadWorker -import javax.inject.Inject - -class EventsFragment : FragmentForDownloadingExternal( - R.layout.fragment_events, - R.string.events_tickets -) { - - @Inject - lateinit var eventsDownloadAction: EventsDownloadAction - - override val method: DownloadWorker.Action - get() = eventsDownloadAction - - private val binding by viewBinding(FragmentEventsBinding::bind) - - override fun onAttach(context: Context) { - super.onAttach(context) - injector.downloadComponent().inject(this) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - setupViewPager(binding.viewPager) - - val eventTab = view.findViewById(R.id.event_tab) - eventTab.setupWithViewPager(binding.viewPager) - - eventTab.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { - override fun onTabSelected(tab: TabLayout.Tab) { - binding.viewPager.currentItem = tab.position - } - - override fun onTabUnselected(tab: TabLayout.Tab) = Unit - - override fun onTabReselected(tab: TabLayout.Tab) = Unit - }) - } - - private fun setupViewPager(viewPager: ViewPager) { - val adapter = EventsViewPagerAdapter(requireContext(), childFragmentManager) - viewPager.adapter = adapter - } - - /** - * This class manages two tabs. - * One of them shows all available events, the other one all booked events. - */ - internal class EventsViewPagerAdapter( - context: Context, - manager: FragmentManager - ) : FragmentPagerAdapter(manager) { - - private val titles = listOf( - context.getString(R.string.all_events), - context.getString(R.string.booked_events) - ) - - override fun getItem(position: Int): Fragment { - val type = if (position == 0) EventType.ALL else EventType.BOOKED - return EventsListFragment.newInstance(type) - } - - override fun getCount(): Int { - return titles.size - } - - override fun getPageTitle(position: Int): CharSequence { - return titles[position] - } - } - - companion object { - @JvmStatic - fun newInstance() = EventsFragment() - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt deleted file mode 100644 index 7a6694137d..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/PaymentConfirmationActivity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.activity - -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity - -class PaymentConfirmationActivity : BaseActivity(R.layout.activity_payment_confirmation) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt deleted file mode 100644 index 3538220ea2..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/activity/ShowTicketActivity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.activity - -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.other.generic.activity.BaseActivity - -class ShowTicketActivity : BaseActivity(R.layout.activity_show_ticket) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt deleted file mode 100644 index 6c58631d1f..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/EventsAdapter.kt +++ /dev/null @@ -1,39 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.adapter - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.overview.CardInteractionListener -import de.tum.`in`.tumcampusapp.component.ui.overview.card.CardViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventItem - -class EventsAdapter : RecyclerView.Adapter() { - - private var events: List = ArrayList() - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardViewHolder { - val layoutRes = R.layout.card_events_item_vertical - val view = LayoutInflater.from(parent.context).inflate(layoutRes, parent, false) - return EventViewHolder(view, null) - } - - override fun getItemViewType(position: Int): Int { - return CARD_INFO - } - - override fun onBindViewHolder(holder: CardViewHolder, position: Int) { - } - - override fun getItemCount() = events.size - - fun update(_es: MutableList) { - } - - class EventViewHolder(view: View, interactionListener: CardInteractionListener?) : CardViewHolder(view, interactionListener) - - companion object { - private const val CARD_INFO = 0 - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/TicketAmountAdapter.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/TicketAmountAdapter.kt deleted file mode 100644 index dad8a63ca7..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/adapter/TicketAmountAdapter.kt +++ /dev/null @@ -1,22 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.adapter - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.ticket.TicketAmountViewHolder -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType - -class TicketAmountAdapter(private val ticketTypes: List) : RecyclerView.Adapter() { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TicketAmountViewHolder { - val view = LayoutInflater.from(parent.context).inflate(R.layout.ticket_amount_row, parent, false) - return TicketAmountViewHolder(view) - } - - override fun onBindViewHolder(holder: TicketAmountViewHolder, position: Int) { - holder.bindToTicketType(ticketTypes[position], position) - } - - override fun getItemCount() = ticketTypes.size -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/di/EventId.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/di/EventId.kt deleted file mode 100644 index 5f637f25f9..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/di/EventId.kt +++ /dev/null @@ -1,6 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.di - -import javax.inject.Named - -@Named("evendId") -annotation class EventId diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt deleted file mode 100644 index 9b774ed73e..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt +++ /dev/null @@ -1,43 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.fragment - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.Fragment -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.Event -import de.tum.`in`.tumcampusapp.utils.Const - -/** - * Fragment for displaying information about an [Event]. Manages content that's shown in the - * PagerAdapter. - */ -class EventDetailsFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return LayoutInflater.from(container?.context).inflate(R.layout.fragment_event_details, container, false) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - } - - override fun onRefresh() { - } - - companion object { - - @JvmStatic - fun newInstance(event: Event): EventDetailsFragment { - return EventDetailsFragment().apply { - arguments = Bundle().apply { - putParcelable(Const.KEY_EVENT, event) - } - } - } - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt deleted file mode 100644 index 0ea163899e..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsViewModel.kt +++ /dev/null @@ -1,9 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.fragment - -import androidx.lifecycle.ViewModel -import de.tum.`in`.tumcampusapp.component.ui.ticket.di.EventId -import javax.inject.Inject - -class EventDetailsViewModel @Inject constructor( - @EventId val eventId: Int -) : ViewModel() diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt deleted file mode 100644 index 86f56a20f1..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventsListFragment.kt +++ /dev/null @@ -1,43 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.fragment - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.Fragment -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout -import de.tum.`in`.tumcampusapp.R -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsViewModel -import de.tum.`in`.tumcampusapp.component.ui.ticket.model.EventType -import javax.inject.Inject -import javax.inject.Provider - -class EventsListFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener { - - @Inject - lateinit var provider: Provider - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.fragment_events_list, container, false) - } - - override fun onRefresh() = Unit - - companion object { - - private const val KEY_EVENT_TYPE = "type" - - @JvmStatic - fun newInstance(eventType: EventType): EventsListFragment { - return EventsListFragment().apply { - arguments = Bundle().apply { - putSerializable(KEY_EVENT_TYPE, eventType) - } - } - } - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Event.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Event.kt index 2add531dcb..4f4dd30c3e 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Event.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Event.kt @@ -8,7 +8,6 @@ import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey import androidx.room.RoomWarnings -import com.google.gson.annotations.SerializedName import de.tum.`in`.tumcampusapp.utils.readDateTime import de.tum.`in`.tumcampusapp.utils.writeDateTime import org.joda.time.DateTime @@ -30,21 +29,16 @@ import org.joda.time.format.DateTimeFormat @SuppressWarnings(RoomWarnings.DEFAULT_CONSTRUCTOR) data class Event( @PrimaryKey - @SerializedName("event") var id: Int = 0, - @SerializedName("file") @ColumnInfo(name = "image_url") var imageUrl: String? = null, var title: String = "", var description: String = "", var locality: String = "", - @SerializedName("start") @ColumnInfo(name = "start_time") var startTime: DateTime = DateTime(), - @SerializedName("end") @ColumnInfo(name = "end_time") var endTime: DateTime? = null, - @SerializedName("link") @ColumnInfo(name = "event_url") var eventUrl: String = "", @ColumnInfo(name = "dismissed") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventBetaInfo.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventBetaInfo.kt deleted file mode 100644 index 198dc0362d..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventBetaInfo.kt +++ /dev/null @@ -1,16 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.model - -class EventBetaInfo : EventItem { - - override fun equals(other: Any?): Boolean { - return (other is EventBetaInfo) - } - - override fun hashCode(): Int { - return javaClass.hashCode() - } - - override fun getIdForComparison(): Int { - return -1 - } -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventType.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventType.kt deleted file mode 100644 index c680b93247..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/EventType.kt +++ /dev/null @@ -1,8 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.model - -import de.tum.`in`.tumcampusapp.R - -enum class EventType(val placeholderTextId: Int, val placeholderImageId: Int) { - ALL(R.string.no_events_found, R.drawable.popcorn_placeholder), - BOOKED(R.string.no_bookings_found, R.drawable.tickets_placeholder) -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Payment.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Payment.kt index 936295f1de..8191c3cada 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Payment.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/Payment.kt @@ -1,11 +1,7 @@ package de.tum.`in`.tumcampusapp.component.ui.ticket.model -import com.google.gson.annotations.SerializedName - data class Payment( - @SerializedName("stripe_publishable_key") var stripePublicKey: String = "", - @SerializedName("terms") var termsLink: String = "", var minTickets: Int = 1, var maxTickets: Int = 1 diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketInfo.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketInfo.kt deleted file mode 100644 index 1763beff0f..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketInfo.kt +++ /dev/null @@ -1,13 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.model - -import androidx.room.Embedded -import androidx.room.Relation - -class TicketInfo { - @Embedded - var ticketType: TicketType? = null - - @Relation(entityColumn = "ticket_type_id", parentColumn = "id") - var tickets: List? = null - var count: Int = 0 -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketType.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketType.kt index e0739b734a..d5b542d627 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketType.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/model/TicketType.kt @@ -4,7 +4,6 @@ import androidx.room.Entity import androidx.room.Ignore import androidx.room.PrimaryKey import androidx.room.RoomWarnings -import com.google.gson.annotations.SerializedName /** * Ticket @@ -17,12 +16,10 @@ import com.google.gson.annotations.SerializedName @SuppressWarnings(RoomWarnings.DEFAULT_CONSTRUCTOR) data class TicketType( @PrimaryKey - @SerializedName("ticket_type") var id: Int = 0, var price: Int = 0, var description: String = "", @Ignore - @SerializedName("payment") var paymentInfo: Payment = Payment(), @Ignore var contingent: Int = 0, diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/EphimeralKey.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/EphimeralKey.kt deleted file mode 100644 index 96df013617..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/EphimeralKey.kt +++ /dev/null @@ -1,8 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.payload - -import com.google.gson.annotations.SerializedName - -data class EphimeralKey( - @SerializedName("api_version") - var apiVersion: String = "" -) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservation.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservation.kt deleted file mode 100644 index 4d6c0a53d4..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservation.kt +++ /dev/null @@ -1,9 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.payload - -import com.google.gson.annotations.SerializedName - -data class TicketReservation( - @SerializedName("ticket_types") - var ticketTypes: Array = emptyArray(), - var amounts: Array = emptyArray() -) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservationResponse.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservationResponse.kt deleted file mode 100644 index 0519eebfe2..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketReservationResponse.kt +++ /dev/null @@ -1,9 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.payload - -import com.google.gson.annotations.SerializedName - -data class TicketReservationResponse( - @SerializedName("ticket_ids") - var ticketIds: ArrayList = ArrayList(), - var error: String? = null -) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketStatus.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketStatus.kt deleted file mode 100644 index 015f96dbeb..0000000000 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/payload/TicketStatus.kt +++ /dev/null @@ -1,16 +0,0 @@ -package de.tum.`in`.tumcampusapp.component.ui.ticket.payload - -import com.google.gson.annotations.SerializedName - -data class TicketStatus( - @SerializedName("ticket_type") - var ticketType: Int = 0, - var contingent: Int = 0, - var sold: Int = 0 -) { - - // is only correct if ticket status represents all TicketTypes - fun isEventWithoutTickets() = contingent <= 0 - fun ticketsStillAvailable() = (contingent - sold) > 0 - fun getRemainingTicketCount() = contingent - sold -} diff --git a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadComponent.kt b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadComponent.kt index 7bd188d71d..ccddba4477 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadComponent.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadComponent.kt @@ -3,14 +3,12 @@ package de.tum.`in`.tumcampusapp.service.di import dagger.Subcomponent import de.tum.`in`.tumcampusapp.component.tumui.grades.GradeNotificationDeleteReceiver import de.tum.`in`.tumcampusapp.component.ui.onboarding.StartupActivity -import de.tum.`in`.tumcampusapp.component.ui.ticket.activity.EventsFragment import de.tum.`in`.tumcampusapp.service.DownloadWorker @Subcomponent(modules = [DownloadModule::class]) interface DownloadComponent { fun inject(downloadWorker: DownloadWorker) - fun inject(eventsFragment: EventsFragment) fun inject(startupActivity: StartupActivity) fun inject(gradeNotificationDeleteReceiver: GradeNotificationDeleteReceiver) } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt index a76908be51..5d5d3fd72d 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/service/di/DownloadModule.kt @@ -17,7 +17,6 @@ import de.tum.`in`.tumcampusapp.component.ui.news.NewsDownloadAction import de.tum.`in`.tumcampusapp.component.ui.news.TopNewsDownloadAction import de.tum.`in`.tumcampusapp.component.ui.news.repository.TopNewsRemoteRepository import de.tum.`in`.tumcampusapp.component.ui.openinghour.LocationImportAction -import de.tum.`in`.tumcampusapp.component.ui.ticket.EventsDownloadAction import de.tum.`in`.tumcampusapp.component.ui.tufilm.FilmDownloadAction import de.tum.`in`.tumcampusapp.component.ui.tufilm.repository.KinoRemoteRepository import de.tum.`in`.tumcampusapp.component.ui.updatenote.UpdateNoteDownloadAction @@ -52,10 +51,6 @@ object DownloadModule { tumCabeClient: TUMCabeClient ): LocationImportAction = LocationImportAction(context, database, tumCabeClient) - @JvmStatic - @Provides - fun provideEventsDownloadAction(): EventsDownloadAction = EventsDownloadAction() - @JvmStatic @Provides fun provideFilmDownloadAction( From 16dc6e5eab968a3fb06b48ff2e029ade3be173ba Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 19:52:31 +0200 Subject: [PATCH 20/22] deleted all asociated layouts --- .../main/res/drawable-nodpi/qr_code_demo.png | Bin 2195 -> 0 bytes .../res/layout-land/activity_show_ticket.xml | 114 --------- .../main/res/layout/activity_buy_ticket.xml | 220 ------------------ .../res/layout/activity_event_details.xml | 36 --- app/src/main/res/layout/activity_events.xml | 24 -- .../main/res/layout/activity_show_ticket.xml | 117 ---------- app/src/main/res/layout/card_events_info.xml | 12 - app/src/main/res/layout/card_events_item.xml | 107 --------- .../res/layout/card_events_item_vertical.xml | 93 -------- .../res/layout/fragment_event_details.xml | 206 ---------------- app/src/main/res/layout/fragment_events.xml | 39 ---- .../main/res/layout/fragment_events_list.xml | 47 ---- app/src/main/res/layout/ticket_amount_row.xml | 66 ------ 13 files changed, 1081 deletions(-) delete mode 100644 app/src/main/res/drawable-nodpi/qr_code_demo.png delete mode 100644 app/src/main/res/layout-land/activity_show_ticket.xml delete mode 100644 app/src/main/res/layout/activity_buy_ticket.xml delete mode 100644 app/src/main/res/layout/activity_event_details.xml delete mode 100644 app/src/main/res/layout/activity_events.xml delete mode 100644 app/src/main/res/layout/activity_show_ticket.xml delete mode 100644 app/src/main/res/layout/card_events_info.xml delete mode 100644 app/src/main/res/layout/card_events_item.xml delete mode 100644 app/src/main/res/layout/card_events_item_vertical.xml delete mode 100644 app/src/main/res/layout/fragment_event_details.xml delete mode 100644 app/src/main/res/layout/fragment_events.xml delete mode 100644 app/src/main/res/layout/fragment_events_list.xml delete mode 100644 app/src/main/res/layout/ticket_amount_row.xml diff --git a/app/src/main/res/drawable-nodpi/qr_code_demo.png b/app/src/main/res/drawable-nodpi/qr_code_demo.png deleted file mode 100644 index 5889884ca928880424e33afb4a5d3437230f15f0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2195 zcmV;E2yFL>P))C<>e|WD(vj+GBPqoMn($@3lkF) zJ3BjNWn~x`7+hRjm6erKQ&UpmrrH1i2hd4GK~#90?VamVDmxH`xvE?g5D-LBa9_ap zf5B5n(!GmbbaiGJ5UjQSIZ1l*4SQE+`jXUY6h%=Km8*JrHIs>(PE}{Q2 z(JoA=TBL@B`vZi8ZFgQUjqf15O%1msBq0e&NJ57&_Lu%i4S%kbaNOESKOA+%pLTcZ zr5?TRzNWo!8W%wbw&1PpK3%xCHo@op;|TNLOG!vV5|VJ=*5t<%4#({;-M>71>7}*& z`g_?*7dF2vq4b>CXB5s-SX)A?D ztS+Bs^w`SNl!O6OI*!l&zJDqM+3 zNW#k(2}yVw4Q+9a?a+rFt^{N{H$^~ekFf0;mmaOuV`7Jny`e+X5uP(lBK&1QFdKNM z5%pXf(nG45UhL3TIMgBRR6v-Yo9GhiG$casKtd9dkc3x6_)!5NtQJBDH8YctP*#i2 zqX{7&83G2I)S%zx&z@=VK0jMR5ab90p=c~E5NyvSj6)(1si7+uI-Y6QPXhu!jZ3Ki zlt@TI5|Z#o5P}ysCR{+*q!O#eI9+(OLvjggy`*=KaJ{|z(x_);37=EX?Qc7Y#$-3* z-rRK}3;eG%R3+~=^=`VLPp!AJHPIdsp(`Qup4C6y*`A=jH*_8j1V8YLA!jbKH5rp%8k~H*KPAZr+t`NJvV`CuQNc7t zo@uOIQ-zrds@P9MLK2dYgqKIC?Lg?R7A~Q#7C+>Vgs=BTF5%{OUmGyJ zFg>I=7768M`qZT7+L&0#!VZM}H1k)v;67+iKnQYoZvg=zC^P|tAQF<0gd`+kB#4j} zCLEh(u`QnXXS>S5df0kOYnR;O#jcAJWBgTy%A%$|dtDEeEd4#R>$bjP$%VUsP;#?D z@agGGhCr12$r=@R0L1Yd)|OOujcw1V?WuBR=Q>E@{{TSfW-8$;wfs%C zo>C8uFRQz}Z-y$N%n!oIN@z{kh=CpG`)Oj?pAPo(&d+3zE4#X}5fYM+ge3efLd_9| z_~BUz<4@vgY-6X9$vx729D26JYAeOC50bw$u}M-RlN0q~d)S;P9J;n-UCGGGe_Ev_ zuS;{eU?;PZhT?f``tM<88{FW+2_%FAZ<PC|EA z!EYt3;%o%bX10GQ?o3L1KIJAd^mXc-jZl-@$+PeYBV@ zjiv{OhLs|WPpv*LAq0p>NJ0{la8IyrqC1VH^jIEESp4ifB{T=&J?LH`>-4uK2rbho zd-_c$+Kvz3e5rR$C-17>ixQSN|1hp}cK5}oQr|%sSF4kdgd`*(3Dbpm7o}?_?8~aW z_EvnCuW6WB zU-=uS7d9;-Aqhzsh=icxgmFF%~7tw>11|3yL)Rze7gO`?_DB!9JV%aLP3Hxx}#6h%?4{sV2v V+1SZ9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_buy_ticket.xml b/app/src/main/res/layout/activity_buy_ticket.xml deleted file mode 100644 index 22c084b431..0000000000 --- a/app/src/main/res/layout/activity_buy_ticket.xml +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_event_details.xml b/app/src/main/res/layout/activity_event_details.xml deleted file mode 100644 index 5610ac5961..0000000000 --- a/app/src/main/res/layout/activity_event_details.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_events.xml b/app/src/main/res/layout/activity_events.xml deleted file mode 100644 index b17ef0333a..0000000000 --- a/app/src/main/res/layout/activity_events.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_show_ticket.xml b/app/src/main/res/layout/activity_show_ticket.xml deleted file mode 100644 index 95a689c755..0000000000 --- a/app/src/main/res/layout/activity_show_ticket.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/card_events_info.xml b/app/src/main/res/layout/card_events_info.xml deleted file mode 100644 index 7510a52e4c..0000000000 --- a/app/src/main/res/layout/card_events_info.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/card_events_item.xml b/app/src/main/res/layout/card_events_item.xml deleted file mode 100644 index be111b8540..0000000000 --- a/app/src/main/res/layout/card_events_item.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/card_events_item_vertical.xml b/app/src/main/res/layout/card_events_item_vertical.xml deleted file mode 100644 index d818ed7cb0..0000000000 --- a/app/src/main/res/layout/card_events_item_vertical.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_event_details.xml b/app/src/main/res/layout/fragment_event_details.xml deleted file mode 100644 index c1bff5957b..0000000000 --- a/app/src/main/res/layout/fragment_event_details.xml +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/fragment_events.xml b/app/src/main/res/layout/fragment_events.xml deleted file mode 100644 index fb5e4bfd96..0000000000 --- a/app/src/main/res/layout/fragment_events.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/fragment_events_list.xml b/app/src/main/res/layout/fragment_events_list.xml deleted file mode 100644 index 6d832e80c0..0000000000 --- a/app/src/main/res/layout/fragment_events_list.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/ticket_amount_row.xml b/app/src/main/res/layout/ticket_amount_row.xml deleted file mode 100644 index fcbc2defb0..0000000000 --- a/app/src/main/res/layout/ticket_amount_row.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file From 43a9c139222f35bc91de8ad69cc5162d51a6da08 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 20:09:39 +0200 Subject: [PATCH 21/22] removed the barcode scanner --- app/build.gradle | 2 - .../in/tumcampusapp/api/app/ApiHelper.java | 43 +------------------ 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 91698c8608..368405c92e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -164,8 +164,6 @@ dependencies { // UI implementation 'com.github.mtotschnig:StickyListHeaders:2.8.0' implementation 'com.github.chrisbanes:PhotoView:2.3.0' - implementation 'me.dm7.barcodescanner:zxing:1.9.13' - implementation 'com.journeyapps:zxing-android-embedded:3.6.0' implementation 'de.psdev.licensesdialog:licensesdialog:2.1.0' implementation 'com.github.thellmund.Android-Week-View:core:4.1.6' implementation 'de.hdodenhof:circleimageview:3.1.0' diff --git a/app/src/main/java/de/tum/in/tumcampusapp/api/app/ApiHelper.java b/app/src/main/java/de/tum/in/tumcampusapp/api/app/ApiHelper.java index 7f84b9d9fb..2a07d0ebd2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/api/app/ApiHelper.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/api/app/ApiHelper.java @@ -2,21 +2,12 @@ import android.content.Context; import android.content.pm.PackageManager; -import android.graphics.Bitmap; import android.os.Build; import com.franmontiel.persistentcookiejar.PersistentCookieJar; import com.franmontiel.persistentcookiejar.cache.SetCookieCache; import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor; -import com.google.zxing.BarcodeFormat; -import com.google.zxing.MultiFormatWriter; -import com.google.zxing.Writer; -import com.google.zxing.WriterException; -import com.google.zxing.common.BitMatrix; -import com.journeyapps.barcodescanner.BarcodeEncoder; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; + import java.util.concurrent.TimeUnit; import de.tum.in.tumcampusapp.BuildConfig; @@ -99,36 +90,4 @@ private static Interceptor getDeviceInterceptor(final Context c) { }; } - /** - * encodes an url - * - * @param pUrl input url - * @return encoded url - */ - public static String encodeUrl(String pUrl) { - try { - return URLEncoder.encode(pUrl, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - /** - * Creates an offline QR-Code - * - * @param message to be encoded - * @return QR-Code or null if there was an error - */ - public static Bitmap createQRCode(String message) { - Writer multiFormatWriter = new MultiFormatWriter(); - try { - BitMatrix bitMatrix = multiFormatWriter.encode(message, BarcodeFormat.QR_CODE, 400, 400); - BarcodeEncoder barcodeEncoder = new BarcodeEncoder(); - return barcodeEncoder.createBitmap(bitMatrix); - } catch (WriterException e) { - Utils.log(e); - return null; - } - } - } From a1c7cb0640e2ed7429a9631c076eb10f96bf380b Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 20 Sep 2023 20:49:34 +0200 Subject: [PATCH 22/22] WTF???? --- app/build.gradle | 2 ++ .../other/generic/activity/ActivityForDownloadingExternal.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 368405c92e..e315930ec0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -164,6 +164,8 @@ dependencies { // UI implementation 'com.github.mtotschnig:StickyListHeaders:2.8.0' implementation 'com.github.chrisbanes:PhotoView:2.3.0' + implementation 'me.dm7.barcodescanner:zxing:1.9.13' // unused, but removal leads to build errors + implementation 'com.journeyapps:zxing-android-embedded:3.6.0' // unused, but removal leads to build errors implementation 'de.psdev.licensesdialog:licensesdialog:2.1.0' implementation 'com.github.thellmund.Android-Week-View:core:4.1.6' implementation 'de.hdodenhof:circleimageview:3.1.0' diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt index 5f885b6ce9..a84da14b6f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt @@ -53,7 +53,7 @@ abstract class ActivityForDownloadingExternal(layoutId: Int) : ProgressActivity< * * @param forceDownload If we should throw away cached data and re-download instead. */ - protected fun requestDownload(forceDownload: CacheControl) { + private fun requestDownload(forceDownload: CacheControl) { if (!NetUtils.isConnected(this)) { Utils.showToast(this, R.string.no_internet_connection) }