Class LearnLevelAttemptRepository
- java.lang.Object
-
- edu.cnm.deepdive.scalescroller.service.LearnLevelAttemptRepository
-
public class LearnLevelAttemptRepository extends Object
LearnLevelAttemptRepositorycontains 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 Completabledelete(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.Completablesave(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
Completableindicating 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
Completableindicating 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:
LiveDataof aLearnLevelAttempt.
-
getAll
public LiveData<List<LearnLevelAttempt>> getAll()
Returns LiveData of all learn level attempts.- Returns:
LiveDataof aListofLearnLevelAttempt.
-
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:
LiveDataof aListofLearnLevelAttempt.
-
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:
LiveDataof aLearnLevelAttempt.
-
-