Class UserController
java.lang.Object
com.example.iconic_raffleevent.controller.UserController
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback interface for adding a user.static interface
Callback interface for deleting a user from the Firestore database.static interface
Callback interface for receiving location data.static interface
Interface for listening to user retrieval callbacks.static interface
Callback interface for profile image removal success or failure.static interface
Callback interface for profile image upload success or failure.static interface
Callback interface for updating a user's profile.static interface
Callback interface for updating a user.static interface
Callback interface for fetching user information.static interface
Callback interface for fetching a list of users from the Firestore database. -
Constructor Summary
ConstructorsConstructorDescriptionUserController
(String userID) Constructor for UserController without needing context.UserController
(String userID, android.content.Context context) Constructor for UserController. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addUser
(User user, UserController.AddUserCallback callback) Adds a new user to the Firebase Firestore database.void
deleteUser
(String userId, UserController.DeleteUserCallback callback) Deletes a user from the Firestore database.void
getAllUsers
(UserController.UserListCallback callback) Fetches the list of all users from the Firestore database.void
Fetches the user data from Firebase Firestore.void
removeProfileImage
(User user, UserController.ProfileImageRemovalCallback callback) Removes the user's profile image from Firebase Storage.void
retrieveUserLocation
(com.google.android.gms.location.FusedLocationProviderClient fusedLocationClient, UserController.OnLocationReceivedCallback callback) Retrieves the user's current location using the FusedLocationProviderClient.void
setGeneralNotificationsEnabled
(User user, boolean enabled) Sets the general notification preference for the user.void
updateProfile
(User user, String name, String email, String phoneNo, UserController.UpdateProfileCallback callback) Updates the profile information of a user.void
uploadProfileImage
(User user, android.net.Uri imageUri, UserController.ProfileImageUploadCallback callback) Uploads the user's profile image to Firebase Storage.
-
Constructor Details
-
UserController
Constructor for UserController.- Parameters:
userID
- The current user ID.context
- The context of the calling activity.
-
UserController
Constructor for UserController without needing context.- Parameters:
userID
- The current user ID.
-
-
Method Details
-
addUser
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
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
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
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
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
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.
-