Class EventHandler

java.lang.Object
com.example.breeze_seas.EventHandler

public class EventHandler extends Object
Class to help manage a list of events with realtime updates and search filters.
  • Constructor Details

    • EventHandler

      public EventHandler(android.app.Activity activity, android.content.Context context, com.google.firebase.firestore.Query q, String userId, boolean hideCoOrganizerEvents, boolean showRegistrableEventsOnly, boolean enableSearchFilter)
      Creates EventHandler based on passed query.
      Parameters:
      activity - Activity object. Used for exiting out of the app when firebase listener fails.
      context - Context object used for displaying toast messages.
      q - Query to generate events from.
      userId - DeviceId of current user. Used for co organizer checks.
      hideCoOrganizerEvents - Boolean dictating whether coOrganized Events should be displayed or not.
      showRegistrableEventsOnly - Boolean dictating to only compute on Events that are currently registrable.
      enableSearchFilter - Boolean dictating whether filter computations should be enabled or not.
  • Method Details

    • setEventShown

      public void setEventShown(Event e)
      Sets the eventShown. This is used to allow other fragments to observe this for event updates.
      Parameters:
      e - The event object.
    • getEventShown

      public androidx.lifecycle.MutableLiveData<Event> getEventShown()
      Gets the eventShown. Other fragments may set up an observer in order to receive realtime updates.
      Returns:
      MutableLiveData encapsulating the event.
    • setKeywordString

      public void setKeywordString(String keywordString)
      Takes the passed string and updates the filteredListOfEvents.
      Parameters:
      keywordString - Keyword search string.
    • setAdvancedFilters

      public void setAdvancedFilters(@Nullable Long availabilityStartMillis, @Nullable Long availabilityEndMillis, @Nullable Integer minCapacityFilter, @Nullable Integer maxCapacityFilter)
      Applies the advanced Explore filters and refreshes the filtered event list.
      Parameters:
      availabilityStartMillis - Start of the selected availability window, or null.
      availabilityEndMillis - End of the selected availability window, or null.
      minCapacityFilter - Minimum capacity filter, or null.
      maxCapacityFilter - Maximum capacity filter, or null.
    • clearAdvancedFilters

      public void clearAdvancedFilters()
      Clears all advanced Explore filters and refreshes the list.
    • getAvailabilityStartMillis

      @Nullable public Long getAvailabilityStartMillis()
      Returns the currently selected availability start.
      Returns:
      Start of the selected availability window, or null.
    • getAvailabilityEndMillis

      @Nullable public Long getAvailabilityEndMillis()
      Returns the currently selected availability end.
      Returns:
      End of the selected availability window, or null.
    • getMinCapacityFilter

      @Nullable public Integer getMinCapacityFilter()
      Returns the selected minimum event capacity filter.
      Returns:
      Minimum capacity filter, or null.
    • getMaxCapacityFilter

      @Nullable public Integer getMaxCapacityFilter()
      Returns the selected maximum event capacity filter.
      Returns:
      Maximum capacity filter, or null.
    • hasAdvancedFilters

      public boolean hasAdvancedFilters()
      Returns whether any advanced Explore filter is active.
      Returns:
      true if at least one advanced filter is set.
    • getActiveFilterCount

      public int getActiveFilterCount()
      Returns the number of advanced Explore filters that are currently active. Date range counts as a single filter pill.
      Returns:
      Number of active advanced filters.
    • getEvents

      public androidx.lifecycle.MutableLiveData<ArrayList<Event>> getEvents()
      Returns the list of event to be shown in the adapter. Use case is for callers to set up observers and update whenever the list changes.
      Returns:
      MutableLiveData wrapping an ArrayList of events.
    • findEventById

      public Event findEventById(String eventId)
      Helper method to find and return event object based on eventId.
      Parameters:
      eventId - String to identify the event object by.
      Returns:
      Event object if present in query hashmap, otherwise null.
    • startListen

      public void startListen()
      Starts listeners to get realtime updates of the event list.
    • stopListen

      public void stopListen()
      Stop fetching realtime updates of event list.