Class LearnLevelAttemptRepository


  • public class LearnLevelAttemptRepository
    extends Object
    LearnLevelAttemptRepository contains methods that provide a layer of abstraction above the LearnLevelAttemptDao, and allows for creation, reading, updating, and deleting of attempts.
    • 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 - The LearnLevelAttempt.
        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 - The LearnLevelAttempt.
        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 a LearnLevelAttempt.
      • getAll

        public LiveData<List<LearnLevelAttempt>> getAll()
        Returns LiveData of all learn level attempts.
        Returns:
        LiveData of a List of LearnLevelAttempt.
      • 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 a List of LearnLevelAttempt.
      • 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 a LearnLevelAttempt.