Class UserRepository


  • public class UserRepository
    extends Object
    UserRepository contains methods that provide a layer of abstraction above the UserDao, and allows for creation, reading, updating, and deleting of attempts.
    • Constructor Detail

      • UserRepository

        public UserRepository​(Context context)
        The constructor initializes the context, the database, the dao, and the GoogleSignInService.
        Parameters:
        context - The application context.
    • Method Detail

      • getOrCreate

        public Single<User> getOrCreate​(@NonNull
                                        GoogleSignInAccount account)
        Creates a player record in the database given a Google Sign In account.
        Parameters:
        account - A GoogleSignInAccount that will be associated with the player.
        Returns:
        A Single User that has been created.
      • save

        public Completable save​(User user)
        Creates or updates a player record in the database.
        Parameters:
        user - The User entity.
        Returns:
        A Completable indicating the success or failure of the creation/update.
      • delete

        public Completable delete​(User user)
        Deletes a user record in the database.
        Parameters:
        user - The Player entity.
        Returns:
        A Completable indicating the success or failure of the deletion.
      • get

        public LiveData<User> get​(long id)
        Returns LiveData on a user, given their id.
        Parameters:
        id - The user's id.
        Returns:
        LiveData of a User.