Class ScaleRepository


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

      • ScaleRepository

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

      • save

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

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

        public LiveData<Scale> get​(long id)
        Returns LiveData of a scale, given its id.
        Parameters:
        id - The id of the scale.
        Returns:
        LiveData of a Scale.
      • getAll

        public LiveData<List<Scale>> getAll()
        Returns LiveData of all scales.
        Returns:
        LiveData of a List of Scale.
      • getAllOrdered

        public LiveData<List<Scale>> getAllOrdered()
        Returns LiveData of all scales, ordered by difficulty.
        Returns:
        LiveData of a List of Scale.
      • getByScaleName

        public LiveData<Scale> getByScaleName​(Mode mode,
                                              Note tonic)
        Returns LiveData of a scale, given its tonic and mode.
        Parameters:
        mode - The mode of the scale.
        tonic - The tonic of the scale.
        Returns:
        LiveData of a Scale.
      • getByTonic

        public LiveData<List<Scale>> getByTonic​(Note tonic)
        Returns LiveData of all scales with the specified tonic.
        Parameters:
        tonic - The tonic of the scale.
        Returns:
        LiveData of a List of Scale.
      • getByMode

        public LiveData<List<Scale>> getByMode​(Mode mode)
        Returns LiveData of all scales with the specified mode.
        Parameters:
        mode - The mode of the scale.
        Returns:
        LiveData of a List of Scale.