Package com.example.breeze_seas
Class AdminViewModel
java.lang.Object
androidx.lifecycle.ViewModel
com.example.breeze_seas.AdminViewModel
public class AdminViewModel
extends androidx.lifecycle.ViewModel
ViewModel for admin screens.
A separate ViewModel from SessionViewModel because admin data (images, events,
profiles) is unrelated to the current-user session state. Keeping them together would give
SessionViewModel too many responsibilities.
This ViewModel is scoped to the activity. Listeners are started only when an
admin browse screen is first opened and remain active for the rest of the activity's
lifetime, even when the user navigates away from admin screens. This means data stays fresh
and no re-fetch is needed when returning to an admin screen. Listeners are only stopped
when the activity finishes and onCleared() is called.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteEvent(Event event, EventDB.EventMutationCallback callback) Deletes an event and its participants subcollection from Firestore.voiddeleteImage(Image image, ImageDB.ImageMutationCallback callback) Deletes an image from Firestore.voiddeleteUser(String deviceId) Deletes a user and all associated data from Firestore.Returns the live event list.Returns the live image list.getUsers()Returns the live user list.protected voidvoidStarts the realtime events listener if not already running.voidStarts the realtime images listener if not already running.voidStarts the realtime users listener if not already running.Methods inherited from class androidx.lifecycle.ViewModel
addCloseable
-
Constructor Details
-
AdminViewModel
public AdminViewModel()
-
-
Method Details
-
getImages
Returns the live image list. -
startImagesListen
public void startImagesListen()Starts the realtime images listener if not already running. -
deleteImage
Deletes an image from Firestore. The listener removes it from the live list automatically. -
getEvents
Returns the live event list. -
startEventsListen
public void startEventsListen()Starts the realtime events listener if not already running. -
deleteEvent
Deletes an event and its participants subcollection from Firestore. The listener removes it from the live list automatically once confirmed. -
getUsers
Returns the live user list. -
startUsersListen
public void startUsersListen()Starts the realtime users listener if not already running. -
deleteUser
Deletes a user and all associated data from Firestore. The listener removes them from the live list automatically once confirmed. -
onCleared
protected void onCleared()- Overrides:
onClearedin classandroidx.lifecycle.ViewModel
-