Class PlayerRepository


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

      • PlayerRepository

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

      • createPlayer

        public Single<Player> createPlayer​(@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 Player that has been created.
      • save

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

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

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

        public LiveData<List<Player>> getAll()
        Returns LiveData on all players.
        Returns:
        LiveData of a List of Player.
      • getByOauth

        public LiveData<Player> getByOauth​(String oauth)
        Returns LiveData on a player, given their OAuth key.
        Parameters:
        oauth - The player's OAuth Key.
        Returns:
        LiveData of a Player.