Class EventViewModel
java.lang.Object
androidx.lifecycle.ViewModel
com.example.slacks_lottoevent.viewmodel.EventViewModel
public class EventViewModel
extends androidx.lifecycle.ViewModel
EventViewModel is a class that provides the UI with the data it needs to display events.
-
Constructor Summary
ConstructorsConstructorDescriptionEventViewModel is a constructor that initializes the EventDB and sets the event change listener. -
Method Summary
Modifier and TypeMethodDescriptiongetEntrantEventsLiveData is a method that returns the entrant events live data.getEventsLiveData is a method that returns the events live data.getHostingEventsLiveData is a method that returns the hosting events live data.void
updateEvent
(Event event) addEvent is a method that adds an event to the database.void
updateEventLists
(List<String> waitlistedIds, List<String> unselectedIds, List<String> invitedIds, List<String> attendingIds) updateEventLists is a method that updates the entrant events live data.void
updateOrganizerEvents
(List<String> eventIds) updateOrganizerEvents is a method that updates the hosting events live data.Methods inherited from class androidx.lifecycle.ViewModel
addCloseable, onCleared
-
Constructor Details
-
EventViewModel
public EventViewModel()EventViewModel is a constructor that initializes the EventDB and sets the event change listener.
-
-
Method Details
-
getEventsLiveData
getEventsLiveData is a method that returns the events live data.- Returns:
- the events live data.
-
getEntrantEventsLiveData
getEntrantEventsLiveData is a method that returns the entrant events live data.- Returns:
- the entrant events live data.
-
getHostingEventsLiveData
getHostingEventsLiveData is a method that returns the hosting events live data.- Returns:
- the hosting events live data.
-
updateEventLists
public void updateEventLists(List<String> waitlistedIds, List<String> unselectedIds, List<String> invitedIds, List<String> attendingIds) updateEventLists is a method that updates the entrant events live data.- Parameters:
waitlistedIds
- is a list of waitlisted event IDs.unselectedIds
- is a list of unselected event IDs.invitedIds
- is a list of invited event IDs.attendingIds
- is a list of attending event IDs.
-
updateOrganizerEvents
updateOrganizerEvents is a method that updates the hosting events live data.- Parameters:
eventIds
- is a list of event IDs.
-
updateEvent
addEvent is a method that adds an event to the database.- Parameters:
event
- is an event to add.
-