Limited number of search items for each category

This commit is contained in:
CappielloAntonio 2021-04-21 14:16:07 +02:00
parent d6b5bf21c1
commit 55c335d7fc
14 changed files with 69 additions and 28 deletions

View file

@ -22,8 +22,8 @@ public interface AlbumDao {
@Query("SELECT * FROM album ORDER BY RANDOM() LIMIT :number;")
LiveData<List<Album>> getSample(int number);
@Query("SELECT * FROM album WHERE title LIKE '%' || :name || '%'")
LiveData<List<Album>> searchAlbum(String name);
@Query("SELECT * FROM album WHERE title LIKE '%' || :name || '%' LIMIT :limit")
LiveData<List<Album>> searchAlbum(String name, int limit);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(Album album);

View file

@ -19,8 +19,8 @@ public interface ArtistDao {
@Query("SELECT * FROM artist ORDER BY RANDOM() LIMIT :number;")
LiveData<List<Artist>> getSample(int number);
@Query("SELECT * FROM artist WHERE name LIKE '%' || :name || '%'")
LiveData<List<Artist>> searchArtist(String name);
@Query("SELECT * FROM artist WHERE name LIKE '%' || :name || '%' LIMIT :limit")
LiveData<List<Artist>> searchArtist(String name, int limit);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<Artist> artists);

View file

@ -29,8 +29,8 @@ public interface GenreDao {
@Query("DELETE FROM genre")
void deleteAll();
@Query("SELECT * FROM genre WHERE name LIKE '%' || :name || '%'")
LiveData<List<Genre>> searchGenre(String name);
@Query("SELECT * FROM genre WHERE name LIKE '%' || :name || '%' LIMIT :limit")
LiveData<List<Genre>> searchGenre(String name, int limit);
@Query("SELECT name FROM genre WHERE name LIKE :query || '%' OR name like '% ' || :query || '%' GROUP BY name LIMIT :number")
List<String> searchSuggestions(String query, int number);

View file

@ -21,8 +21,8 @@ public interface SongDao {
@Query("SELECT * FROM song")
List<Song> getAllList();
@Query("SELECT * FROM song WHERE title LIKE '%' || :title || '%'")
LiveData<List<Song>> searchSong(String title);
@Query("SELECT * FROM song WHERE title LIKE '%' || :title || '%' LIMIT :limit")
LiveData<List<Song>> searchSong(String title, int limit);
// Da utilizzare in caso si decidesse di migliorare il viewpager nella home
@Query("SELECT * FROM song WHERE id IN (:pseudoRandomNumber)")