Class LearnLevelAttemptRepository
- java.lang.Object
-
- edu.cnm.deepdive.scalescroller.service.LearnLevelAttemptRepository
-
public class LearnLevelAttemptRepository extends Object
LearnLevelAttemptRepository
contains methods that provide a layer of abstraction above theLearnLevelAttemptDao
, and allows for creation, reading, updating, and deleting of attempts.
-
-
Constructor Summary
Constructors Constructor Description LearnLevelAttemptRepository(Context context)
The constructor initializes the context, the database, and the dao.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Completable
delete(LearnLevelAttempt attempt)
Deletes a attempt record in the database.LiveData<LearnLevelAttempt>
get(long id)
Returns LiveData of a learn level attempt, given its id.LiveData<List<LearnLevelAttempt>>
getAll()
Returns LiveData of all learn level attempts.LiveData<List<LearnLevelAttempt>>
getAllByPlayer(long playerId)
Returns LiveData of all learn level attempts made by a specific player.LiveData<LearnLevelAttempt>
getHighestDifficulty(long playerId)
Returns LiveData of the learn level attempt with the highest difficulty rating.Completable
save(LearnLevelAttempt attempt)
Creates or updates a attempt record in the database.
-
-
-
Constructor Detail
-
LearnLevelAttemptRepository
public LearnLevelAttemptRepository(Context context)
The constructor initializes the context, the database, and the dao.- Parameters:
context
- The application context.
-
-
Method Detail
-
save
public Completable save(LearnLevelAttempt attempt)
Creates or updates a attempt record in the database.- Parameters:
attempt
- TheLearnLevelAttempt
.- Returns:
- A
Completable
indicating the success or failure of the creation/update.
-
delete
public Completable delete(LearnLevelAttempt attempt)
Deletes a attempt record in the database.- Parameters:
attempt
- TheLearnLevelAttempt
.- Returns:
- A
Completable
indicating the success or failure of the deletion.
-
get
public LiveData<LearnLevelAttempt> get(long id)
Returns LiveData of a learn level attempt, given its id.- Parameters:
id
- The id of the attempt.- Returns:
LiveData
of aLearnLevelAttempt
.
-
getAll
public LiveData<List<LearnLevelAttempt>> getAll()
Returns LiveData of all learn level attempts.- Returns:
LiveData
of aList
ofLearnLevelAttempt
.
-
getAllByPlayer
public LiveData<List<LearnLevelAttempt>> getAllByPlayer(long playerId)
Returns LiveData of all learn level attempts made by a specific player.- Parameters:
playerId
- The player's id.- Returns:
LiveData
of aList
ofLearnLevelAttempt
.
-
getHighestDifficulty
public LiveData<LearnLevelAttempt> getHighestDifficulty(long playerId)
Returns LiveData of the learn level attempt with the highest difficulty rating.- Parameters:
playerId
- The player's id.- Returns:
LiveData
of aLearnLevelAttempt
.
-
-