Add song/genre sync

This commit is contained in:
Antonio Cappiello 2020-11-24 10:52:00 +01:00
parent b2c269a051
commit 76037e487b
47 changed files with 703 additions and 89 deletions

View file

@ -18,6 +18,9 @@ public interface GenreDao {
@Query("SELECT * FROM genre")
LiveData<List<Genre>> getAll();
@Query("SELECT * FROM genre")
List<Genre> getGenreList();
@Query("SELECT * FROM genre ORDER BY RANDOM() LIMIT :number;")
LiveData<List<Genre>> getSample(int number);

View file

@ -35,9 +35,15 @@ public interface SongDao {
@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 * FROM song WHERE artistId = :artistID ORDER BY play_count DESC")
LiveData<List<Song>> getArtistTopSongs(String artistID);
@Query("SELECT * FROM song WHERE albumId = :albumID ORDER BY trackNumber ASC")
LiveData<List<Song>> getAlbumSong(String albumID);
@Query("SELECT * FROM song INNER Join song_genre_cross ON song.id = song_genre_cross.song_id AND song_genre_cross.genre_id = :genreID")
LiveData<List<Song>> getSongByGenre(String genreID);
@Query("SELECT EXISTS(SELECT * FROM song WHERE id = :id)")
boolean exist(String id);

View file

@ -0,0 +1,35 @@
package com.cappielloantonio.play.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
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;
import com.cappielloantonio.play.model.SongGenreCross;
import java.util.List;
@Dao
public interface SongGenreCrossDao {
@Query("SELECT * FROM song_genre_cross")
LiveData<List<SongGenreCross>> getAll();
@Query("SELECT EXISTS(SELECT * FROM song_genre_cross WHERE id = :id)")
boolean exist(String id);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(SongGenreCross songGenreCross);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<SongGenreCross> songGenreCrosses);
@Delete
void delete(SongGenreCross songGenreCross);
@Update
void update(SongGenreCross songGenreCross);
}