2020-08-21 17:07:10 +00:00
|
|
|
package code.name.monkey.retromusic.db
|
|
|
|
|
|
|
|
import code.name.monkey.retromusic.model.Song
|
|
|
|
|
2020-09-26 20:39:07 +00:00
|
|
|
fun List<HistoryEntity>.fromHistoryToSongs(): List<Song> {
|
|
|
|
return map {
|
|
|
|
it.toSong()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-21 17:07:10 +00:00
|
|
|
fun List<SongEntity>.toSongs(): List<Song> {
|
|
|
|
return map {
|
|
|
|
it.toSong()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-17 21:25:41 +00:00
|
|
|
fun List<Song>.toSongs(playlistId: Long): List<SongEntity> {
|
2020-08-24 16:30:53 +00:00
|
|
|
return map {
|
|
|
|
it.toSongEntity(playlistId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:01:55 +00:00
|
|
|
fun Song.toHistoryEntity(timePlayed: Long): HistoryEntity {
|
|
|
|
return HistoryEntity(
|
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
trackNumber = trackNumber,
|
|
|
|
year = year,
|
|
|
|
duration = duration,
|
|
|
|
data = data,
|
|
|
|
dateModified = dateModified,
|
|
|
|
albumId = albumId,
|
|
|
|
albumName = albumName,
|
|
|
|
artistId = artistId,
|
|
|
|
artistName = artistName,
|
|
|
|
composer = composer,
|
|
|
|
albumArtist = albumArtist,
|
|
|
|
timePlayed = timePlayed
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun Song.toSongEntity(playListId: Long): SongEntity {
|
|
|
|
return SongEntity(
|
|
|
|
playlistCreatorId = playListId,
|
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
trackNumber = trackNumber,
|
|
|
|
year = year,
|
|
|
|
duration = duration,
|
|
|
|
data = data,
|
|
|
|
dateModified = dateModified,
|
|
|
|
albumId = albumId,
|
|
|
|
albumName = albumName,
|
|
|
|
artistId = artistId,
|
|
|
|
artistName = artistName,
|
|
|
|
composer = composer,
|
|
|
|
albumArtist = albumArtist
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-21 17:07:10 +00:00
|
|
|
fun SongEntity.toSong(): Song {
|
|
|
|
return Song(
|
2020-09-17 21:25:41 +00:00
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
trackNumber = trackNumber,
|
|
|
|
year = year,
|
|
|
|
duration = duration,
|
|
|
|
data = data,
|
|
|
|
dateModified = dateModified,
|
|
|
|
albumId = albumId,
|
|
|
|
albumName = albumName,
|
|
|
|
artistId = artistId,
|
|
|
|
artistName = artistName,
|
|
|
|
composer = composer,
|
|
|
|
albumArtist = albumArtist
|
2020-08-21 17:07:10 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun PlayCountEntity.toSong(): Song {
|
|
|
|
return Song(
|
2020-09-17 21:25:41 +00:00
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
trackNumber = trackNumber,
|
|
|
|
year = year,
|
|
|
|
duration = duration,
|
|
|
|
data = data,
|
|
|
|
dateModified = dateModified,
|
|
|
|
albumId = albumId,
|
|
|
|
albumName = albumName,
|
|
|
|
artistId = artistId,
|
|
|
|
artistName = artistName,
|
|
|
|
composer = composer,
|
|
|
|
albumArtist = albumArtist
|
2020-08-21 17:07:10 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun HistoryEntity.toSong(): Song {
|
|
|
|
return Song(
|
2020-09-17 21:25:41 +00:00
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
trackNumber = trackNumber,
|
|
|
|
year = year,
|
|
|
|
duration = duration,
|
|
|
|
data = data,
|
|
|
|
dateModified = dateModified,
|
|
|
|
albumId = albumId,
|
|
|
|
albumName = albumName,
|
|
|
|
artistId = artistId,
|
|
|
|
artistName = artistName,
|
|
|
|
composer = composer,
|
|
|
|
albumArtist = albumArtist
|
2020-08-21 17:07:10 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun Song.toPlayCount(): PlayCountEntity {
|
|
|
|
return PlayCountEntity(
|
2020-09-17 21:25:41 +00:00
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
trackNumber = trackNumber,
|
|
|
|
year = year,
|
|
|
|
duration = duration,
|
|
|
|
data = data,
|
|
|
|
dateModified = dateModified,
|
|
|
|
albumId = albumId,
|
|
|
|
albumName = albumName,
|
|
|
|
artistId = artistId,
|
|
|
|
artistName = artistName,
|
|
|
|
composer = composer,
|
|
|
|
albumArtist = albumArtist,
|
|
|
|
timePlayed = System.currentTimeMillis(),
|
|
|
|
playCount = 1
|
2020-08-21 17:07:10 +00:00
|
|
|
)
|
2020-09-05 18:51:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fun List<Song>.toSongsEntity(playlistEntity: PlaylistEntity): List<SongEntity> {
|
|
|
|
return map {
|
|
|
|
it.toSongEntity(playlistEntity.playListId)
|
|
|
|
}
|
|
|
|
}
|
2020-09-26 20:39:07 +00:00
|
|
|
|