Package com.example.breeze_seas
Class StatusList
java.lang.Object
com.example.breeze_seas.StatusList
- Direct Known Subclasses:
AcceptedList,DeclinedList,PendingList,WaitingList
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface to communicate result of asynchronous database tasks back to the UI. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUser(User user, StatusList.ListUpdateListener listener) Adds or updates a user in the event's participant sub-collection.voiddetermineLocation(android.content.Context context, User user, StatusList.ListUpdateListener listener) Determines the user's current GPS location if the event requires it.intgetEvent()intgetSize()protected abstract StringReturns the status string used for database queries.voidRemoves a user from the local memory list by ID.voidremoveUserFromDB(String deviceId, StatusList.ListUpdateListener listener) Removes a user from the event's participant sub-collection in Firestore.voidsetCapacity(int capacity) voidstartListening(StatusList.ListUpdateListener listener) Attaches a SnapshotListener to Firestore to monitor participants with a specific status.voidDetaches the Firestore listener and clears the local user list.booleanuserIsInList(User user) Checks if a user is already present in the local list.
-
Field Details
-
userList
-
capacity
protected int capacity -
event
-
tempLocation
protected com.google.firebase.firestore.GeoPoint tempLocation
-
-
Constructor Details
-
StatusList
Constructor for StatusList.- Parameters:
event- TheEventobject associated with this list.capacity- The maximum number of users allowed in this specific list.
-
-
Method Details
-
startListening
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
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
Adds or updates a user in the event's participant sub-collection.- Parameters:
user- TheUserobject to be added.listener- Callback to handle success or failure of the DB operation.
-
removeUserFromDB
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
- Returns:
- The
Eventobject 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
Removes a user from the local memory list by ID.- Parameters:
userId- The ID of the user to remove.
-
getUserList
- Returns:
- The current local ArrayList of Users in this list.
-
userIsInList
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.
-