Class EventController
java.lang.Object
com.example.iconic_raffleevent.controller.EventController
EventController handles the logic related to event creation, modification, and management.
It communicates between the event model and the view components.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback interface for accepting an event invitation.static interface
Callback interface for declining an event invitation.static interface
Callback interface for handling success or failure of an event deletion operation.static interface
Callback interface for event details fetch operations.static interface
Callback interface for fetching all events.static interface
Callback interface for event map fetch operations.static interface
Callback interface for retrieving a waitliststatic interface
Callback interface for joining a waiting list.static interface
Callback interface for removing a location.static interface
Callback interface for leaving a waiting list.static interface
Callback interface for scanning a QR code.static interface
static interface
Callback interface for updating event details.static interface
Callback interface for uploading an event poster.static interface
Callback interface for uploading an event QR code. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new EventController instance and initializes FirebaseAttendee. -
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptEventInvitation
(String eventId, String userId, EventController.AcceptInvitationCallback callback) Accepts an event invitation for the user.void
declineEventInvitation
(String eventId, String userId, EventController.DeclineInvitationCallback callback) Declines an event invitation for the user.void
deleteEvent
(String eventId, EventController.DeleteEventCallback callback) Deletes an event by its ID.void
deleteEventWithMedia
(String eventId, EventController.DeleteEventCallback callback) Deletes an event along with its associated media (poster and QR code).void
Fetches all available events.void
getAllUserEvents
(String userId, EventController.EventListCallback callback) Fetches the events a user is in a waiting list for or an owner ofvoid
getEventDetails
(String eventId, EventController.EventDetailsCallback callback) Fetches event details for a given event ID.void
getEventMap
(String eventId, EventController.EventMapCallback callback) Fetches the map locations associated with a given event.void
getUserWaitingListEvents
(String userId, EventController.EventListCallback callback) Fetches the list of events a user is waiting for.void
joinWaitingListWithLocation
(String eventId, User user, com.google.firebase.firestore.GeoPoint userLocation, EventController.JoinWaitingListCallback callback) Adds a user to the event's waiting list with their location.void
joinWaitingListWithoutLocation
(String eventId, String userId, EventController.JoinWaitingListCallback callback) Adds a user to the event's waiting list without their location.void
leaveLocationsList
(Event event, String userId, EventController.LeaveLocationsListCallback callback) Removes a user from the event's locations map.void
leaveWaitingList
(Event event, User user, EventController.LeaveWaitingListCallback callback) Removes a user from the event's waiting list.void
saveEventToDatabase
(Event event, User user) Saves an event to the database.void
scanQRCode
(String qrCodeData, EventController.ScanQRCodeCallback callback) Scan a qrcode from the users camera and returns the eventvoid
sendNotification
(Notification notification, EventController.SendDrawNotificationCallback callback) Creates a notification in the Notification collection indicates if a user was selected for an eventvoid
setWaitingListLimit
(String eventId, int waitingListLimit, EventController.UpdateEventCallback callback) Validates and sets the waiting list limit for an event.void
updateEventDetails
(Event eventObj) Update an existing events information in the databasevoid
uploadEventPoster
(android.net.Uri imageUri, Event eventObj, EventController.UploadEventPosterCallback callback) Uploads an event poster to Firebase Storage.void
uploadEventQRCode
(Event eventObj, EventController.UploadEventQRCodeCallback callback) Uploads an event QR code to Firebase Storage.
-
Constructor Details
-
EventController
public EventController()Constructs a new EventController instance and initializes FirebaseAttendee.
-
-
Method Details
-
getEventDetails
Fetches event details for a given event ID.- Parameters:
eventId
- The ID of the event.callback
- The callback to handle the fetched event details or error.
-
getEventMap
Fetches the map locations associated with a given event.- Parameters:
eventId
- The ID of the event.callback
- The callback to handle the fetched locations or error.
-
getAllEvents
Fetches all available events.- Parameters:
callback
- The callback to handle the fetched events or error.
-
setWaitingListLimit
public void setWaitingListLimit(String eventId, int waitingListLimit, EventController.UpdateEventCallback callback) Validates and sets the waiting list limit for an event. Ensures that the limit is greater than or equal to the current waiting list size.- Parameters:
eventId
- The ID of the event.waitingListLimit
- The new waiting list limit.callback
- Callback to handle success or error.
-
joinWaitingListWithLocation
public void joinWaitingListWithLocation(String eventId, User user, com.google.firebase.firestore.GeoPoint userLocation, EventController.JoinWaitingListCallback callback) Adds a user to the event's waiting list with their location. Checks if the waiting list limit has been reached before adding the user.- Parameters:
eventId
- The ID of the event.user
- The user.userLocation
- The location of the user.callback
- The callback to handle success or error.
-
joinWaitingListWithoutLocation
public void joinWaitingListWithoutLocation(String eventId, String userId, EventController.JoinWaitingListCallback callback) Adds a user to the event's waiting list without their location. Checks if the waiting list limit has been reached before adding the user.- Parameters:
eventId
- The ID of the event.userId
- The ID of the user.callback
- The callback to handle success or error.
-
leaveWaitingList
public void leaveWaitingList(Event event, User user, EventController.LeaveWaitingListCallback callback) Removes a user from the event's waiting list.- Parameters:
event
- The event we are removing the user fromuser
- The user.callback
- The callback to handle success or error.
-
leaveLocationsList
public void leaveLocationsList(Event event, String userId, EventController.LeaveLocationsListCallback callback) Removes a user from the event's locations map.- Parameters:
event
- The event we are removing the users location fromuserId
- The user ID.callback
- The callback to handle success or error.
-
acceptEventInvitation
public void acceptEventInvitation(String eventId, String userId, EventController.AcceptInvitationCallback callback) Accepts an event invitation for the user.- Parameters:
eventId
- The ID of the event.userId
- The ID of the user.callback
- The callback to handle success or error.
-
declineEventInvitation
public void declineEventInvitation(String eventId, String userId, EventController.DeclineInvitationCallback callback) Declines an event invitation for the user.- Parameters:
eventId
- The ID of the event.userId
- The ID of the user.callback
- The callback to handle success or error.
-
saveEventToDatabase
Saves an event to the database.- Parameters:
event
- The event object to save.user
- The user associated with the event.
-
uploadEventPoster
public void uploadEventPoster(android.net.Uri imageUri, Event eventObj, EventController.UploadEventPosterCallback callback) Uploads an event poster to Firebase Storage.- Parameters:
imageUri
- The URI of the image to upload.eventObj
- The event object associated with the poster.callback
- The callback to handle success or error.
-
uploadEventQRCode
Uploads an event QR code to Firebase Storage.- Parameters:
eventObj
- The event object associated with the QR code.callback
- The callback to handle success or error.
-
updateEventDetails
Update an existing events information in the database- Parameters:
eventObj
- event being updated
-
scanQRCode
Scan a qrcode from the users camera and returns the event- Parameters:
callback
- The callback to handle the fetched events or error.qrCodeData
- The qr code data embedded in the qrcode image
-
getUserWaitingListEvents
Fetches the list of events a user is waiting for.- Parameters:
userId
- The ID of the user.callback
- The callback to handle the fetched events or error.
-
getAllUserEvents
Fetches the events a user is in a waiting list for or an owner of- Parameters:
userId
- The ID of the usercallback
- The callback to handle the fetched events or error
-
deleteEventWithMedia
Deletes an event along with its associated media (poster and QR code).- Parameters:
eventId
- The ID of the event to be deleted.callback
- The callback interface to notify the success or failure of the operation.
-
deleteEvent
Deletes an event by its ID.- Parameters:
eventId
- The ID of the event to be deleted.callback
- The callback interface to notify the success or failure of the operation.
-
sendNotification
public void sendNotification(Notification notification, EventController.SendDrawNotificationCallback callback) Creates a notification in the Notification collection indicates if a user was selected for an event- Parameters:
notification
- notification to be createdcallback
- The callback to handle success or error
-