Package com.kernelcrew.moodapp.data
Class UserProvider
java.lang.Object
com.kernelcrew.moodapp.data.UserProvider
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSnapshotListenerForUser
(String uid, com.google.firebase.firestore.EventListener<com.google.firebase.firestore.DocumentSnapshot> listener) Add a listener for changes made to a specific user.fetchFollowers
(String uid) Fetch all users following a specific user.fetchFollowing
(String uid) Fetch all users followed by a specific user.com.google.android.gms.tasks.Task<String>
fetchUsername
(String uid) Fetch the username for a specific user.static UserProvider
Get the singleton instance of UserProvidercom.google.android.gms.tasks.Task<String>
getUsername
(String uid) Fetch the username of a specific user.searchUsers
(String query, String currentUserId) Search users by username (case-insensitive, partial-match) while excluding the current user.
-
Method Details
-
getInstance
Get the singleton instance of UserProvider- Returns:
- Singleton instance of UserProvider
-
getUsername
Fetch the username of a specific user.- Parameters:
uid
- The user to find the username of.- Returns:
- The user's username.
-
fetchFollowers
Fetch all users following a specific user.- Parameters:
uid
- The user to look up the followers of.- Returns:
- All users following this user.
-
fetchFollowing
Fetch all users followed by a specific user.- Parameters:
uid
- The user to look up the following of.- Returns:
- All users followed by this user.
-
addSnapshotListenerForUser
public void addSnapshotListenerForUser(@NonNull String uid, @NonNull com.google.firebase.firestore.EventListener<com.google.firebase.firestore.DocumentSnapshot> listener) Add a listener for changes made to a specific user.- Parameters:
uid
- Id of the user to listen to.listener
- Snapshot listener to attach.
-
searchUsers
public com.google.android.gms.tasks.Task<List<User>> searchUsers(String query, @NonNull String currentUserId) Search users by username (case-insensitive, partial-match) while excluding the current user.- Parameters:
query
- The search string.currentUserId
- The current user's ID to exclude.- Returns:
- A Task that returns a List of matching Users.
-
fetchUsername
Fetch the username for a specific user.- Parameters:
uid
- The user ID whose username to fetch.- Returns:
- A Task containing the username as a String.
-