Class PlayerRepository
- java.lang.Object
-
- edu.cnm.deepdive.scalescroller.service.PlayerRepository
-
-
Constructor Summary
Constructors Constructor Description PlayerRepository(Context context)
The constructor initializes the context, the database, the dao, and the GoogleSignInService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Single<Player>
createPlayer(GoogleSignInAccount account)
Creates a player record in the database given a Google Sign In account.Completable
delete(Player player)
Deletes a player record in the database.LiveData<Player>
get(long id)
Returns LiveData on a player, given their id.LiveData<List<Player>>
getAll()
Returns LiveData on all players.LiveData<Player>
getByOauth(String oauth)
Returns LiveData on a player, given their OAuth key.Completable
save(Player player)
Creates or updates a player record in the database.
-
-
-
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
- ThePlayer
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
- ThePlayer
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 aPlayer
.
-
getAll
public LiveData<List<Player>> getAll()
Returns LiveData on all players.- Returns:
LiveData
of aList
ofPlayer
.
-
-