Package com.example.breeze_seas
Class Event
java.lang.Object
com.example.breeze_seas.Event
Event stores the organizer-facing and entrant-facing metadata for a single event document.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback Interface for when event detects a realtime update.static interfaceCallback interface for whenfetchOrganizerNames(fetchOrganizerNamesCallback)finishes.static interfaceCallback interface for whenfetchLists(ListsLoadedCallback)finishes. -
Constructor Summary
ConstructorsConstructorDescriptionEvent(boolean isPrivate, String organizerId, String name, String description, Image image, com.google.firebase.Timestamp registrationStartTimestamp, com.google.firebase.Timestamp registrationEndTimestamp, com.google.firebase.Timestamp eventStartTimestamp, com.google.firebase.Timestamp eventEndTimestamp, boolean geolocationEnforced, int eventCapacity, int waitingListCapacity) Creates a new event for organizer-side event creation before it is persisted.Event(String eventId, boolean isPrivate, String organizerId, ArrayList<String> coOrganizerId, String name, String description, Image image, com.google.firebase.Timestamp createdTimestamp, com.google.firebase.Timestamp modifiedTimestamp, com.google.firebase.Timestamp registrationStartTimestamp, com.google.firebase.Timestamp registrationEndTimestamp, com.google.firebase.Timestamp eventStartTimestamp, com.google.firebase.Timestamp eventEndTimestamp, boolean geolocationEnforced, int eventCapacity, int waitingListCapacity, int drawARound, WaitingList waitingList, PendingList pendingList, AcceptedList acceptedList, DeclinedList declinedList) Creates an event using the full field set expected when hydrating fromEventDB.Creates a minimal event instance for temporary or test organizer flows.Creates an event from Firebase using a map object. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.firebase.Timestampcreated()Short forgetCreatedTimestamp()com.google.firebase.TimestampeventEnd()Short forgetEventEndTimestamp()com.google.firebase.TimestampShort forgetEventStartTimestamp()voidfetchLists(Event.ListsLoadedCallback callback) Helper method to query and generate and populate lists with user objects.voidObtains the names of the organizer tied to this event.Returns the accepted-list helper associated with this event.Returns a list of all user IDs that are any kind of organizers.Returns a list of user IDs that are co-organizers.com.google.firebase.TimestampReturns the timestamp when the event was created.Returns the declined-list helper associated with this event.Returns the organizer-provided description for this event.intReturns the current draw-round counter for this event.intReturns the event-capacity limit for accepted entrants.com.google.firebase.TimestampReturns the event end timestamp.Returns the unique identifier for this event.com.google.firebase.TimestampReturns the event start timestamp.getImage()Returns the image object associated with the event.android.graphics.BitmapReturns bitmap of event poster to caller.androidx.lifecycle.MutableLiveData<Image> Returns the image object wrapped in a MutableLiveData.com.google.firebase.TimestampReturns the timestamp when the event was last modified.getName()Returns the display name of the event.Returns the organizer identifier that owns this event.Returns the pending-list helper associated with this event.android.graphics.BitmapSynonym ofgetImageBitmap()long(DEPRECATED) Returns the registration-start timestamp as epoch milliseconds.com.google.firebase.TimestampReturns the timestamp when registration closes.com.google.firebase.TimestampReturns the timestamp when registration opens.long(DEPRECATED) Returns the registration-end timestamp as epoch milliseconds.Returns the waiting-list helper associated with this event.(DEPRECATED) Returns the waiting-list capacity using the older nullable helper style.intReturns the maximum waiting-list capacity for the event.booleanReturns whether registration for this event enforces geolocation.booleanReturns the private state for this event.voidLoads the map object from Firestore and updates the event details accordingly.com.google.firebase.Timestampmodified()Short forgetCreatedTimestamp()voidResyncs the list objects with information from the dbcom.google.firebase.TimestampregEnd()Short forgetRegistrationEndTimestamp()com.google.firebase.TimestampregStart()Short forgetRegistrationStartTimestamp()voidsetAcceptedList(AcceptedList acceptedList) Updates the accepted-list helper associated with this event.voidsetCoOrganizerId(ArrayList<String> coOrganizerId) Set the list of user IDs that are co-organizers.voidsetCreatedTimestamp(com.google.firebase.Timestamp createdTimestamp) Updates the event creation timestamp.voidsetDeclinedList(DeclinedList declinedList) Updates the declined-list helper associated with this event.voidsetDescription(String description) Updates the description for this event.voidsetDrawARound(int drawARound) Updates the draw-round counter for this event.voidsetEventCapacity(int eventCapacity) Updates the event-capacity limit for accepted entrants.voidsetEventEndTimestamp(com.google.firebase.Timestamp eventEndTimestamp) Updates the event end timestamp.voidsetEventId(String eventId) Updates the unique identifier for this event.voidsetEventStartTimestamp(com.google.firebase.Timestamp eventStartTimestamp) Updates the event start timestamp.voidUpdates the image object associated with the event.voidsetModifiedTimestamp(com.google.firebase.Timestamp modifiedTimestamp) Updates the last-modified timestamp.voidUpdates the display name of the event.voidsetOrganizerId(String organizerId) Updates the organizer identifier associated with this event.voidsetPendingList(PendingList pendingList) Updates the pending-list helper associated with this event.voidsetPrivate(boolean isPrivate) Sets the private state for this event.voidsetRegistrationEndTimestamp(com.google.firebase.Timestamp registrationEndTimestamp) Updates the registration closing timestamp.voidsetRegistrationStartTimestamp(com.google.firebase.Timestamp registrationStartTimestamp) Updates the registration opening timestamp.voidsetWaitingList(WaitingList waitingList) Updates the waiting-list helper associated with this event.voidsetWaitingListCapacity(int waitingListCapacity) Updates the maximum waiting-list capacity for the event.voidstartEventListen(Event.EventUpdatedCallback callback) Method to get realtime updates of event.voidstartImageListen(String imageDocId) Activates an image listener for the given event.voidStart realtime listeners on all list classes.voidStop fetching realtime updates of event.voidStop fetching realtime updates of image pertaining to this event.voidStop realtime listeners on all list classes.toMap()Serializes the current event into the Firestore map shape expected byEventDB.toString()Generates a string representation of the event object.booleanuserIsAnOrganizer(User user) Method to check if a user is any kind of organizer of the eventbooleanuserIsCoOrganizer(User user) Method to check if a user is a co-organizer of the eventbooleanuserIsOrganizer(User user) Method to check if a user is the ORIGINAL organizer of the event
-
Constructor Details
-
Event
public Event(String eventId, boolean isPrivate, String organizerId, ArrayList<String> coOrganizerId, String name, String description, Image image, com.google.firebase.Timestamp createdTimestamp, com.google.firebase.Timestamp modifiedTimestamp, com.google.firebase.Timestamp registrationStartTimestamp, com.google.firebase.Timestamp registrationEndTimestamp, com.google.firebase.Timestamp eventStartTimestamp, com.google.firebase.Timestamp eventEndTimestamp, boolean geolocationEnforced, int eventCapacity, int waitingListCapacity, int drawARound, WaitingList waitingList, PendingList pendingList, AcceptedList acceptedList, DeclinedList declinedList) Creates an event using the full field set expected when hydrating fromEventDB.- Parameters:
eventId- Unique event identifier.isPrivate- Whether event is private.organizerId- Organizer identifier that owns the event.coOrganizerId- Other organizers that manages the event.name- Display name of the event.description- Organizer-provided description.image- Image object.createdTimestamp- Timestamp when the event was created.modifiedTimestamp- Timestamp when the event was last modified.registrationStartTimestamp- Registration opening timestamp.registrationEndTimestamp- Registration closing timestamp.eventStartTimestamp- Event start timestamp.eventEndTimestamp- Event end timestamp.geolocationEnforced- Whether registration requires geolocation.eventCapacity- Maximum accepted entrants.waitingListCapacity- Maximum waiting-list entrants.drawARound- Current draw round counter.waitingList- Waiting-list helper associated with the event.pendingList- Pending-list helper associated with the event.acceptedList- Accepted-list helper associated with the event.declinedList- Declined-list helper associated with the event.
-
Event
Creates an event from Firebase using a map object.- Parameters:
map- Map object to retrieve and initialize values from.
-
Event
public Event(boolean isPrivate, String organizerId, String name, String description, Image image, com.google.firebase.Timestamp registrationStartTimestamp, com.google.firebase.Timestamp registrationEndTimestamp, com.google.firebase.Timestamp eventStartTimestamp, com.google.firebase.Timestamp eventEndTimestamp, boolean geolocationEnforced, int eventCapacity, int waitingListCapacity) Creates a new event for organizer-side event creation before it is persisted.- Parameters:
isPrivate- Whether event is private.organizerId- Organizer identifier that owns the new event.name- Display name of the event.description- Organizer-provided description.image- Image object.registrationStartTimestamp- Registration opening timestamp.registrationEndTimestamp- Registration closing timestamp.eventStartTimestamp- Event start timestamp.eventEndTimestamp- Event end timestamp.geolocationEnforced- Whether registration requires geolocation.eventCapacity- Maximum accepted entrants.waitingListCapacity- Maximum waiting-list entrants.
-
Event
Creates a minimal event instance for temporary or test organizer flows.- Parameters:
organizerId- Organizer identifier that owns the event.eventCapacity- Maximum accepted entrants.
-
-
Method Details
-
toMap
Serializes the current event into the Firestore map shape expected byEventDB.- Returns:
- Firestore field map for this event.
-
loadMap
Loads the map object from Firestore and updates the event details accordingly. DOES NOT LOAD COMPLEX OBJECTS LIKE participants (the lists classes) and image- Parameters:
map- Map object to populate attribute from.
-
getEventId
Returns the unique identifier for this event.- Returns:
- Event identifier.
-
setEventId
Updates the unique identifier for this event.- Parameters:
eventId- Event identifier to store.
-
isPrivate
public boolean isPrivate()Returns the private state for this event.- Returns:
- Private state.
-
setPrivate
public void setPrivate(boolean isPrivate) Sets the private state for this event.- Parameters:
isPrivate- Private state.
-
getOrganizerId
Returns the organizer identifier that owns this event.- Returns:
- Organizer identifier.
-
setOrganizerId
Updates the organizer identifier associated with this event.- Parameters:
organizerId- Organizer identifier to store.
-
getCoOrganizerId
Returns a list of user IDs that are co-organizers.- Returns:
- Arraylist of IDs.
-
setCoOrganizerId
Set the list of user IDs that are co-organizers.- Parameters:
coOrganizerId- Arraylist of IDs.
-
getAllOrganizerId
Returns a list of all user IDs that are any kind of organizers. -
userIsOrganizer
Method to check if a user is the ORIGINAL organizer of the event- Parameters:
user- User object- Returns:
- true is user is the ORIGINAL organizer of event, otherwise false
-
userIsCoOrganizer
Method to check if a user is a co-organizer of the event- Parameters:
user- User object- Returns:
- true is user is a co-organizer of event, otherwise false
-
userIsAnOrganizer
Method to check if a user is any kind of organizer of the event- Parameters:
user- User object- Returns:
- true is user is any kind of organizer of event, otherwise false
-
getName
Returns the display name of the event.- Returns:
- Event name.
-
setName
Updates the display name of the event.- Parameters:
name- Event name to store.
-
getDescription
Returns the organizer-provided description for this event.- Returns:
- Event description.
-
setDescription
Updates the description for this event.- Parameters:
description- Event description to store.
-
getImage
Returns the image object associated with the event.- Returns:
- Image object.
-
setImage
Updates the image object associated with the event.- Parameters:
image- Image object to hold a reference to.
-
getImageData
Returns the image object wrapped in a MutableLiveData. Suitable for use when fragments need to observe when images get updated.- Returns:
- MutableLiveData that encloses an image object.
-
getPosterBitmap
public android.graphics.Bitmap getPosterBitmap()Synonym ofgetImageBitmap()- Returns:
- Bitmap of event poster. Null if image object does not exist.
-
getImageBitmap
public android.graphics.Bitmap getImageBitmap()Returns bitmap of event poster to caller.- Returns:
- Bitmap of event poster. Null if image object does not exist.
-
getCreatedTimestamp
public com.google.firebase.Timestamp getCreatedTimestamp()Returns the timestamp when the event was created.- Returns:
- Event creation timestamp.
-
created
public com.google.firebase.Timestamp created()Short forgetCreatedTimestamp()- Returns:
- Event creation timestamp.
-
setCreatedTimestamp
public void setCreatedTimestamp(com.google.firebase.Timestamp createdTimestamp) Updates the event creation timestamp.- Parameters:
createdTimestamp- Creation timestamp to store.
-
getModifiedTimestamp
public com.google.firebase.Timestamp getModifiedTimestamp()Returns the timestamp when the event was last modified.- Returns:
- Last-modified timestamp.
-
modified
public com.google.firebase.Timestamp modified()Short forgetCreatedTimestamp()- Returns:
- Last-modified timestamp.
-
setModifiedTimestamp
public void setModifiedTimestamp(com.google.firebase.Timestamp modifiedTimestamp) Updates the last-modified timestamp.- Parameters:
modifiedTimestamp- Last-modified timestamp to store.
-
getRegistrationStartTimestamp
public com.google.firebase.Timestamp getRegistrationStartTimestamp()Returns the timestamp when registration opens.- Returns:
- Registration opening timestamp.
-
regStart
public com.google.firebase.Timestamp regStart()Short forgetRegistrationStartTimestamp()- Returns:
- Registration opening timestamp.
-
getRegFromMillis
public long getRegFromMillis()(DEPRECATED) Returns the registration-start timestamp as epoch milliseconds.- Returns:
- Registration start timestamp in milliseconds, or
0Lif unavailable.
-
setRegistrationStartTimestamp
public void setRegistrationStartTimestamp(com.google.firebase.Timestamp registrationStartTimestamp) Updates the registration opening timestamp.- Parameters:
registrationStartTimestamp- Registration opening timestamp to store.
-
getRegistrationEndTimestamp
public com.google.firebase.Timestamp getRegistrationEndTimestamp()Returns the timestamp when registration closes.- Returns:
- Registration closing timestamp.
-
regEnd
public com.google.firebase.Timestamp regEnd()Short forgetRegistrationEndTimestamp()- Returns:
- Registration closing timestamp
-
getRegToMillis
public long getRegToMillis()(DEPRECATED) Returns the registration-end timestamp as epoch milliseconds.- Returns:
- Registration end timestamp in milliseconds, or
0Lif unavailable.
-
setRegistrationEndTimestamp
public void setRegistrationEndTimestamp(com.google.firebase.Timestamp registrationEndTimestamp) Updates the registration closing timestamp.- Parameters:
registrationEndTimestamp- Registration closing timestamp to store.
-
getEventStartTimestamp
public com.google.firebase.Timestamp getEventStartTimestamp()Returns the event start timestamp.- Returns:
- Event start timestamp.
-
eventStart
public com.google.firebase.Timestamp eventStart()Short forgetEventStartTimestamp()- Returns:
- Event start timestamp.
-
setEventStartTimestamp
public void setEventStartTimestamp(com.google.firebase.Timestamp eventStartTimestamp) Updates the event start timestamp.- Parameters:
eventStartTimestamp- Event start timestamp to store.
-
getEventEndTimestamp
public com.google.firebase.Timestamp getEventEndTimestamp()Returns the event end timestamp.- Returns:
- Event end timestamp.
-
eventEnd
public com.google.firebase.Timestamp eventEnd()Short forgetEventEndTimestamp()- Returns:
- Event end timestamp.
-
setEventEndTimestamp
public void setEventEndTimestamp(com.google.firebase.Timestamp eventEndTimestamp) Updates the event end timestamp.- Parameters:
eventEndTimestamp- Event end timestamp to store.
-
isGeolocationEnforced
public boolean isGeolocationEnforced()Returns whether registration for this event enforces geolocation.- Returns:
trueif geolocation checks are required.
-
getEventCapacity
public int getEventCapacity()Returns the event-capacity limit for accepted entrants.- Returns:
- Event-capacity limit.
-
setEventCapacity
public void setEventCapacity(int eventCapacity) Updates the event-capacity limit for accepted entrants.- Parameters:
eventCapacity- Event-capacity limit to store.
-
getWaitingListCapacity
public int getWaitingListCapacity()Returns the maximum waiting-list capacity for the event.- Returns:
- Waiting-list capacity, or a negative value when effectively unlimited.
-
getWaitingListCap
(DEPRECATED) Returns the waiting-list capacity using the older nullable helper style.- Returns:
- Waiting-list capacity, or
nullif the event is effectively unlimited.
-
setWaitingListCapacity
public void setWaitingListCapacity(int waitingListCapacity) Updates the maximum waiting-list capacity for the event.- Parameters:
waitingListCapacity- Waiting-list capacity to store.
-
getDrawARound
public int getDrawARound()Returns the current draw-round counter for this event.- Returns:
- Draw-round counter.
-
setDrawARound
public void setDrawARound(int drawARound) Updates the draw-round counter for this event.- Parameters:
drawARound- Draw-round counter to store.
-
getWaitingList
Returns the waiting-list helper associated with this event.- Returns:
- Waiting-list helper.
-
setWaitingList
Updates the waiting-list helper associated with this event.- Parameters:
waitingList- Waiting-list helper to store.
-
getPendingList
Returns the pending-list helper associated with this event.- Returns:
- Pending-list helper.
-
setPendingList
Updates the pending-list helper associated with this event.- Parameters:
pendingList- Pending-list helper to store.
-
getAcceptedList
Returns the accepted-list helper associated with this event.- Returns:
- Accepted-list helper.
-
setAcceptedList
Updates the accepted-list helper associated with this event.- Parameters:
acceptedList- Accepted-list helper to store.
-
getDeclinedList
Returns the declined-list helper associated with this event.- Returns:
- Declined-list helper.
-
setDeclinedList
Updates the declined-list helper associated with this event.- Parameters:
declinedList- Declined-list helper to store.
-
startEventListen
Method to get realtime updates of event. -
stopEventListen
public void stopEventListen()Stop fetching realtime updates of event. -
startListenAllLists
Start realtime listeners on all list classes.- Parameters:
listener- The callback function to be called when a list class detects an update.
-
stopListenAllLists
public void stopListenAllLists()Stop realtime listeners on all list classes. -
startImageListen
Activates an image listener for the given event.- Parameters:
imageDocId- Image Document Id to listen at.
-
stopImageListen
public void stopImageListen()Stop fetching realtime updates of image pertaining to this event. -
fetchLists
Helper method to query and generate and populate lists with user objects.- Parameters:
callback- Callback method after firebase transaction.
-
refreshListsFromDB
public void refreshListsFromDB()Resyncs the list objects with information from the db -
fetchOrganizerNames
Obtains the names of the organizer tied to this event. -
toString
Generates a string representation of the event object. Useful when filtering for specific keywords.
-