Add artist page

This commit is contained in:
Antonio Cappiello 2020-11-22 19:11:38 +01:00
parent 8b7e383dc2
commit c2be2711b9
44 changed files with 1028 additions and 191 deletions

View file

@ -8,7 +8,6 @@ import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import com.cappielloantonio.play.model.Album;
import com.cappielloantonio.play.model.Song;
import java.util.List;
@ -17,9 +16,15 @@ public interface AlbumDao {
@Query("SELECT * FROM album")
LiveData<List<Album>> getAll();
@Query("SELECT * FROM album WHERE artistId = :artistId;")
LiveData<List<Album>> getArtistAlbums(String artistId);
@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 EXISTS(SELECT * FROM album WHERE id = :id)")
boolean exist(String id);

View file

@ -7,7 +7,6 @@ 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 java.util.List;
@ -20,6 +19,9 @@ 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 EXISTS(SELECT * FROM artist WHERE id = :id)")
boolean exist(String id);

View file

@ -6,6 +6,7 @@ import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
import com.cappielloantonio.play.model.Song;
@ -22,15 +23,18 @@ public interface SongDao {
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
LiveData<List<Song>> getDiscoverSample(int number);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
@Query("SELECT * FROM song ORDER BY added DESC LIMIT :number")
LiveData<List<Song>> getRecentlyAddedSample(int number);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
@Query("SELECT * FROM song WHERE last_play != 0 ORDER BY last_play DESC LIMIT :number")
LiveData<List<Song>> getRecentlyPlayedSample(int number);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
@Query("SELECT * FROM song WHERE play_count != 0 ORDER BY play_count DESC LIMIT :number")
LiveData<List<Song>> getMostPlayedSample(int number);
@Query("SELECT * FROM song WHERE play_count != 0 AND artistId = :artistID ORDER BY play_count DESC LIMIT :number")
LiveData<List<Song>> getArtistTopSongsSample(String artistID, int number);
@Query("SELECT EXISTS(SELECT * FROM song WHERE id = :id)")
boolean exist(String id);
@ -42,4 +46,10 @@ public interface SongDao {
@Delete
void delete(Song song);
@Update
public void update(Song song);
@Query("SELECT * FROM song ORDER BY RANDOM() LIMIT :number")
List<Song> random(int number);
}