Class ScaleChallengeAttemptRepository


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

      • ScaleChallengeAttemptRepository

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

      • save

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

        public Completable delete​(ScaleChallengeAttempt attempt)
        Deletes a attempt record in the database.
        Parameters:
        attempt - The ScaleChallengeAttempt.
        Returns:
        A Completable indicating the success or failure of the deletion.
      • getScaleChallengeAttempt

        public LiveData<ScaleChallengeAttempt> getScaleChallengeAttempt​(long id)
        Returns LiveData of a scale-challenge attempt, given its id.
        Parameters:
        id - The id of the attempt.
        Returns:
        LiveData of a ScaleChallengeAttempt.
      • getAllScaleChallengeAttempts

        public LiveData<List<ScaleChallengeAttempt>> getAllScaleChallengeAttempts()
        Returns LiveData of all scale-challenge attempts.
        Returns:
        LiveData of a List of ScaleChallengeAttempt.
      • getChallengeAttemptsForScaleOrderByScore

        public LiveData<List<ChallengeAttempt>> getChallengeAttemptsForScaleOrderByScore​(long scaleId)
        Returns LiveData of all challenge attempts that use a particular scale, ordered by score.
        Parameters:
        scaleId - The scale's id.
        Returns:
        LiveData of a List of ChallengeAttempt.
      • getChallengeAttemptsForScaleOrderByDate

        public LiveData<List<ChallengeAttempt>> getChallengeAttemptsForScaleOrderByDate​(long scaleId)
        Returns LiveData of all challenge attempts that use a particular scale, ordered by date.
        Parameters:
        scaleId - The scale's id.
        Returns:
        LiveData of a List of ChallengeAttempt.
      • getScalesForChallengeAttemptOrderByName

        public LiveData<List<Scale>> getScalesForChallengeAttemptOrderByName​(long attemptId)
        Returns LiveData of all scales used in a particular attempt, ordered by scale name.
        Parameters:
        attemptId - The attempt's id.
        Returns:
        LiveData of a List of Scale.
      • getScalesForChallengeAttemptOrderByDate

        public LiveData<List<Scale>> getScalesForChallengeAttemptOrderByDate​(long attemptId)
        Returns LiveData of all scales used in a particular attempt, ordered by date.
        Parameters:
        attemptId - The attempt's id.
        Returns:
        LiveData of a List of Scale.