Add catalogues

This commit is contained in:
Antonio Cappiello 2020-11-21 18:41:35 +01:00
parent 8c889f7a38
commit 8b7e383dc2
45 changed files with 1084 additions and 136 deletions

View file

@ -17,6 +17,9 @@ public interface AlbumDao {
@Query("SELECT * FROM album")
LiveData<List<Album>> getAll();
@Query("SELECT * FROM album ORDER BY RANDOM() LIMIT :number;")
LiveData<List<Album>> getSample(int number);
@Query("SELECT EXISTS(SELECT * FROM album WHERE id = :id)")
boolean exist(String id);

View file

@ -17,6 +17,9 @@ public interface ArtistDao {
@Query("SELECT * FROM artist")
LiveData<List<Artist>> getAll();
@Query("SELECT * FROM artist ORDER BY RANDOM() LIMIT :number;")
LiveData<List<Artist>> getSample(int number);
@Query("SELECT EXISTS(SELECT * FROM artist WHERE id = :id)")
boolean exist(String id);

View file

@ -7,6 +7,7 @@ import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Artist;
import com.cappielloantonio.play.model.Genre;
@ -17,6 +18,9 @@ public interface GenreDao {
@Query("SELECT * FROM genre")
LiveData<List<Genre>> getAll();
@Query("SELECT * FROM genre ORDER BY RANDOM() LIMIT :number;")
LiveData<List<Genre>> getSample(int number);
@Query("SELECT EXISTS(SELECT * FROM genre WHERE id = :id)")
boolean exist(String id);

View file

@ -19,6 +19,18 @@ public interface SongDao {
@Query("SELECT * FROM song WHERE title LIKE '%' || :title || '%'")
LiveData<List<Song>> searchSong(String title);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
LiveData<List<Song>> getDiscoverSample(int number);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
LiveData<List<Song>> getRecentlyAddedSample(int number);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
LiveData<List<Song>> getRecentlyPlayedSample(int number);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
LiveData<List<Song>> getMostPlayedSample(int number);
@Query("SELECT EXISTS(SELECT * FROM song WHERE id = :id)")
boolean exist(String id);