Playlist Add, Delete, Add Songs
This commit is contained in:
parent
6aa9b08ff2
commit
f3988ae1d1
51 changed files with 551 additions and 137 deletions
|
@ -4,16 +4,21 @@ import androidx.room.*
|
|||
|
||||
@Dao
|
||||
interface PlaylistDao {
|
||||
@Insert
|
||||
suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long
|
||||
|
||||
@Query("UPDATE PlaylistEntity SET playlist_name = :name WHERE playlist_id = :playlistId")
|
||||
suspend fun renamePlaylistEntity(playlistId: Int, name: String)
|
||||
|
||||
@Query("SELECT * FROM PlaylistEntity WHERE playlist_name = :name")
|
||||
suspend fun checkPlaylistExists(name: String): List<PlaylistEntity>
|
||||
|
||||
@Insert
|
||||
suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long
|
||||
|
||||
@Query("SELECT * FROM PlaylistEntity")
|
||||
suspend fun playlists(): List<PlaylistEntity>
|
||||
|
||||
@Query("DELETE FROM SongEntity WHERE playlist_creator_id = :playlistId")
|
||||
suspend fun deleteSongsFromPlaylist(playlistId: Int)
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM PlaylistEntity")
|
||||
suspend fun playlistsWithSong(): List<PlaylistWithSongs>
|
||||
|
@ -24,9 +29,16 @@ interface PlaylistDao {
|
|||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id = :playlistName AND id = :songId")
|
||||
suspend fun checkSongExistsWithPlaylistName(playlistName: String, songId: Int): List<SongEntity>
|
||||
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id = :playlistId ORDER BY title")
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id = :playlistId")
|
||||
suspend fun getSongs(playlistId: Int): List<SongEntity>
|
||||
|
||||
@Delete
|
||||
suspend fun deletePlaylistEntity(playlistWithSongs: PlaylistWithSongs)
|
||||
suspend fun deletePlaylistEntity(playlistEntity: PlaylistEntity)
|
||||
|
||||
@Delete
|
||||
suspend fun deletePlaylistEntities(playlistEntities: List<PlaylistEntity>)
|
||||
|
||||
@Delete
|
||||
suspend fun removeSongsFromPlaylist(songs: List<SongEntity>)
|
||||
|
||||
}
|
|
@ -13,4 +13,5 @@ data class PlaylistWithSongs(
|
|||
entityColumn = "playlist_creator_id"
|
||||
)
|
||||
val songs: List<SongEntity>
|
||||
):Parcelable
|
||||
):Parcelable
|
||||
|
||||
|
|
|
@ -54,4 +54,10 @@ class SongEntity(
|
|||
albumArtist
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun List<SongEntity>.toSongs(): List<Song> {
|
||||
return map {
|
||||
it.toSong()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue