Class StatusList

java.lang.Object
com.example.breeze_seas.StatusList
Direct Known Subclasses:
AcceptedList, DeclinedList, PendingList, WaitingList

public abstract class StatusList extends Object
A super class for that manages a list of participants for an event. It handles real-time database synchronization with Firestore, manages user status transitions, handles geolocation requirements, and facilitates promotion of users to co-organizers.
  • Field Details

    • userList

      protected ArrayList<User> userList
    • capacity

      protected int capacity
    • event

      protected Event event
    • tempLocation

      protected com.google.firebase.firestore.GeoPoint tempLocation
  • Constructor Details

    • StatusList

      public StatusList(Event event, int capacity)
      Constructor for StatusList.
      Parameters:
      event - The Event object associated with this list.
      capacity - The maximum number of users allowed in this specific list.
  • Method Details

    • startListening

      public void startListening(StatusList.ListUpdateListener listener)
      Attaches a SnapshotListener to Firestore to monitor participants with a specific status. This provides real-time updates and when a user's status changes in the DB, they are automatically added to or removed from this list in the UI.
      Parameters:
      listener - The listener to notify when the local list has been synchronized.
    • stopListening

      public void stopListening()
      Detaches the Firestore listener and clears the local user list.
    • getStatusName

      protected abstract String getStatusName()
      Returns the status string used for database queries.
      Returns:
      String representing the status (e.g., "waiting", "selected").
    • determineLocation

      public void determineLocation(android.content.Context context, User user, StatusList.ListUpdateListener listener)
      Determines the user's current GPS location if the event requires it. If geolocation is not enforced, it proceeds directly to adding the user.
      Parameters:
      context - The application or activity context.
      user - The user object requesting to join.
      listener - Callback for completion.
    • addUser

      public void addUser(User user, StatusList.ListUpdateListener listener)
      Adds or updates a user in the event's participant sub-collection.
      Parameters:
      user - The User object to be added.
      listener - Callback to handle success or failure of the DB operation.
    • removeUserFromDB

      public void removeUserFromDB(String deviceId, StatusList.ListUpdateListener listener)
      Removes a user from the event's participant sub-collection in Firestore.
      Parameters:
      deviceId - The deviceId of the User that is to be removed.
      listener - Callback to handle success or failure of the DB operation.
    • getEvent

      public Event getEvent()
      Returns:
      The Event object associated with this list.
    • getCapacity

      public int getCapacity()
      Returns:
      The maximum capacity of this status list.
    • setCapacity

      public void setCapacity(int capacity)
      Parameters:
      capacity - The new capacity to set for this status list.
    • popUser

      public void popUser(String userId)
      Removes a user from the local memory list by ID.
      Parameters:
      userId - The ID of the user to remove.
    • getUserList

      public ArrayList<User> getUserList()
      Returns:
      The current local ArrayList of Users in this list.
    • userIsInList

      public boolean userIsInList(User user)
      Checks if a user is already present in the local list.
      Parameters:
      user - The user to check.
      Returns:
      True if found, false otherwise.
    • getSize

      public int getSize()
      Returns:
      The number of users currently in the local list.