Class UserProvider

java.lang.Object
com.kernelcrew.moodapp.data.UserProvider

public class UserProvider extends Object
  • Method Details

    • getInstance

      public static UserProvider getInstance()
      Get the singleton instance of UserProvider
      Returns:
      Singleton instance of UserProvider
    • getUsername

      public com.google.android.gms.tasks.Task<String> getUsername(@NonNull String uid)
      Fetch the username of a specific user.
      Parameters:
      uid - The user to find the username of.
      Returns:
      The user's username.
    • fetchFollowers

      public com.google.android.gms.tasks.Task<List<User>> fetchFollowers(@NonNull String uid)
      Fetch all users following a specific user.
      Parameters:
      uid - The user to look up the followers of.
      Returns:
      All users following this user.
    • fetchFollowing

      public com.google.android.gms.tasks.Task<List<User>> fetchFollowing(@NonNull String uid)
      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

      public com.google.android.gms.tasks.Task<String> fetchUsername(@NonNull String uid)
      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.