Class UserController

java.lang.Object
com.example.iconic_raffleevent.controller.UserController

public class UserController extends Object
UserController is a controller class that manages user-related functionalities such as adding a user, updating user profiles, uploading/removing profile images, enabling/disabling notifications, and fetching user data from Firebase.
  • Constructor Details

    • UserController

      public UserController(String userID, android.content.Context context)
      Constructor for UserController.
      Parameters:
      userID - The current user ID.
      context - The context of the calling activity.
    • UserController

      public UserController(String userID)
      Constructor for UserController without needing context.
      Parameters:
      userID - The current user ID.
  • Method Details

    • addUser

      public void addUser(User user, UserController.AddUserCallback callback)
      Adds a new user to the Firebase Firestore database.
      Parameters:
      user - The User object containing user information.
      callback - The callback to notify on success or failure.
    • updateProfile

      public void updateProfile(User user, String name, String email, String phoneNo, UserController.UpdateProfileCallback callback)
      Updates the profile information of a user.
      Parameters:
      user - The User object to update.
      name - The new name of the user.
      email - The new email of the user.
      phoneNo - The new phone number of the user.
      callback - The callback to notify the result of the update operation.
    • uploadProfileImage

      public void uploadProfileImage(User user, android.net.Uri imageUri, UserController.ProfileImageUploadCallback callback)
      Uploads the user's profile image to Firebase Storage.
      Parameters:
      user - The user whose profile image is being uploaded.
      imageUri - The URI of the image to upload.
      callback - The callback to notify on success or failure.
    • removeProfileImage

      public void removeProfileImage(User user, UserController.ProfileImageRemovalCallback callback)
      Removes the user's profile image from Firebase Storage.
      Parameters:
      user - The user whose profile image is being removed.
      callback - The callback to notify on success or failure.
    • setGeneralNotificationsEnabled

      public void setGeneralNotificationsEnabled(User user, boolean enabled)
      Sets the general notification preference for the user.
      Parameters:
      user - The user whose general notification preference is being updated.
      enabled - True to enable general notifications, false to disable.
    • getUserInformation

      public void getUserInformation(UserController.UserFetchCallback callback)
      Fetches the user data from Firebase Firestore.
      Parameters:
      callback - The callback to notify with the fetched user or an error message.
    • retrieveUserLocation

      public void retrieveUserLocation(com.google.android.gms.location.FusedLocationProviderClient fusedLocationClient, UserController.OnLocationReceivedCallback callback)
      Retrieves the user's current location using the FusedLocationProviderClient.
      Parameters:
      fusedLocationClient - The location client to fetch the user's location.
      callback - The callback to notify with the retrieved location or an error message.
    • getAllUsers

      public void getAllUsers(UserController.UserListCallback callback)
      Fetches the list of all users from the Firestore database. This method retrieves all documents from the "User" collection in Firestore.
      Parameters:
      callback - The callback to notify on the result of the fetch operation. The callback will be invoked with either the list of users or an error message.
    • deleteUser

      public void deleteUser(String userId, UserController.DeleteUserCallback callback)
      Deletes a user from the Firestore database. This method deletes the user document from the "User" collection in Firestore.
      Parameters:
      userId - The unique identifier of the user to be deleted.
      callback - The callback to notify on the result of the delete operation. The callback will be invoked with either a success message or an error message.