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 interfaceCallback interface for accepting an event invitation.static interfaceCallback interface for declining an event invitation.static interfaceCallback interface for handling success or failure of an event deletion operation.static interfaceCallback interface for event details fetch operations.static interfaceCallback interface for fetching all events.static interfaceCallback interface for event map fetch operations.static interfaceCallback interface for retrieving a waitliststatic interfaceCallback interface for joining a waiting list.static interfaceCallback interface for removing a location.static interfaceCallback interface for leaving a waiting list.static interfaceCallback interface for scanning a QR code.static interfacestatic interfaceCallback interface for updating event details.static interfaceCallback interface for uploading an event poster.static interfaceCallback interface for uploading an event QR code. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new EventController instance and initializes FirebaseAttendee. -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptEventInvitation(String eventId, String userId, EventController.AcceptInvitationCallback callback) Accepts an event invitation for the user.voiddeclineEventInvitation(String eventId, String userId, EventController.DeclineInvitationCallback callback) Declines an event invitation for the user.voiddeleteEvent(String eventId, EventController.DeleteEventCallback callback) Deletes an event by its ID.voiddeleteEventWithMedia(String eventId, EventController.DeleteEventCallback callback) Deletes an event along with its associated media (poster and QR code).voidFetches all available events.voidgetAllUserEvents(String userId, EventController.EventListCallback callback) Fetches the events a user is in a waiting list for or an owner ofvoidgetEventDetails(String eventId, EventController.EventDetailsCallback callback) Fetches event details for a given event ID.voidgetEventMap(String eventId, EventController.EventMapCallback callback) Fetches the map locations associated with a given event.voidgetUserWaitingListEvents(String userId, EventController.EventListCallback callback) Fetches the list of events a user is waiting for.voidjoinWaitingListWithLocation(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.voidjoinWaitingListWithoutLocation(String eventId, String userId, EventController.JoinWaitingListCallback callback) Adds a user to the event's waiting list without their location.voidleaveLocationsList(Event event, String userId, EventController.LeaveLocationsListCallback callback) Removes a user from the event's locations map.voidleaveWaitingList(Event event, User user, EventController.LeaveWaitingListCallback callback) Removes a user from the event's waiting list.voidsaveEventToDatabase(Event event, User user) Saves an event to the database.voidscanQRCode(String qrCodeData, EventController.ScanQRCodeCallback callback) Scan a qrcode from the users camera and returns the eventvoidsendNotification(Notification notification, EventController.SendDrawNotificationCallback callback) Creates a notification in the Notification collection indicates if a user was selected for an eventvoidsetWaitingListLimit(String eventId, int waitingListLimit, EventController.UpdateEventCallback callback) Validates and sets the waiting list limit for an event.voidupdateEventDetails(Event eventObj) Update an existing events information in the databasevoiduploadEventPoster(android.net.Uri imageUri, Event eventObj, EventController.UploadEventPosterCallback callback) Uploads an event poster to Firebase Storage.voiduploadEventQRCode(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
-