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 Details

    • AdminViewModel

      public AdminViewModel()
  • Method Details

    • getImages

      public androidx.lifecycle.MutableLiveData<List<Image>> getImages()
      Returns the live image list.
    • startImagesListen

      public void startImagesListen()
      Starts the realtime images listener if not already running.
    • deleteImage

      public void deleteImage(Image image, ImageDB.ImageMutationCallback callback)
      Deletes an image from Firestore. The listener removes it from the live list automatically.
    • getEvents

      public androidx.lifecycle.MutableLiveData<List<Event>> getEvents()
      Returns the live event list.
    • startEventsListen

      public void startEventsListen()
      Starts the realtime events listener if not already running.
    • deleteEvent

      public void deleteEvent(Event event, EventDB.EventMutationCallback callback)
      Deletes an event and its participants subcollection from Firestore. The listener removes it from the live list automatically once confirmed.
    • getUsers

      public androidx.lifecycle.MutableLiveData<List<User>> getUsers()
      Returns the live user list.
    • startUsersListen

      public void startUsersListen()
      Starts the realtime users listener if not already running.
    • deleteUser

      public void deleteUser(String deviceId)
      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:
      onCleared in class androidx.lifecycle.ViewModel