- migrated ids from int
to long
- some cleaning
This commit is contained in:
parent
90bca59192
commit
9e46d74507
58 changed files with 708 additions and 635 deletions
|
@ -13,7 +13,7 @@ interface HistoryDao {
|
|||
suspend fun insertSongInHistory(historyEntity: HistoryEntity)
|
||||
|
||||
@Query("SELECT * FROM HistoryEntity WHERE id = :songId LIMIT 1")
|
||||
suspend fun isSongPresentInHistory(songId: Int): HistoryEntity?
|
||||
suspend fun isSongPresentInHistory(songId: Long): HistoryEntity?
|
||||
|
||||
@Update
|
||||
suspend fun updateHistorySong(historyEntity: HistoryEntity)
|
||||
|
|
|
@ -7,7 +7,7 @@ import androidx.room.PrimaryKey
|
|||
@Entity
|
||||
class HistoryEntity(
|
||||
@PrimaryKey
|
||||
val id: Int,
|
||||
val id: Long,
|
||||
val title: String,
|
||||
@ColumnInfo(name = "track_number")
|
||||
val trackNumber: Int,
|
||||
|
@ -17,11 +17,11 @@ class HistoryEntity(
|
|||
@ColumnInfo(name = "date_modified")
|
||||
val dateModified: Long,
|
||||
@ColumnInfo(name = "album_id")
|
||||
val albumId: Int,
|
||||
val albumId: Long,
|
||||
@ColumnInfo(name = "album_name")
|
||||
val albumName: String,
|
||||
@ColumnInfo(name = "artist_id")
|
||||
val artistId: Int,
|
||||
val artistId: Long,
|
||||
@ColumnInfo(name = "artist_name")
|
||||
val artistName: String,
|
||||
val composer: String?,
|
||||
|
|
|
@ -14,14 +14,14 @@ interface PlayCountDao {
|
|||
fun deleteSongInPlayCount(playCountEntity: PlayCountEntity)
|
||||
|
||||
@Query("SELECT * FROM PlayCountEntity WHERE id =:songId")
|
||||
fun checkSongExistInPlayCount(songId: Int): List<PlayCountEntity>
|
||||
fun checkSongExistInPlayCount(songId: Long): List<PlayCountEntity>
|
||||
|
||||
@Query("SELECT * FROM PlayCountEntity ORDER BY play_count DESC")
|
||||
fun playCountSongs(): List<PlayCountEntity>
|
||||
|
||||
@Query("DELETE FROM SongEntity WHERE id =:songId")
|
||||
fun deleteSong(songId: Int)
|
||||
fun deleteSong(songId: Long)
|
||||
|
||||
@Query("UPDATE PlayCountEntity SET play_count = play_count + 1 WHERE id = :id")
|
||||
fun updateQuantity(id: Int)
|
||||
fun updateQuantity(id: Long)
|
||||
}
|
|
@ -7,7 +7,7 @@ import androidx.room.PrimaryKey
|
|||
@Entity
|
||||
class PlayCountEntity(
|
||||
@PrimaryKey
|
||||
val id: Int,
|
||||
val id: Long,
|
||||
val title: String,
|
||||
@ColumnInfo(name = "track_number")
|
||||
val trackNumber: Int,
|
||||
|
@ -17,11 +17,11 @@ class PlayCountEntity(
|
|||
@ColumnInfo(name = "date_modified")
|
||||
val dateModified: Long,
|
||||
@ColumnInfo(name = "album_id")
|
||||
val albumId: Int,
|
||||
val albumId: Long,
|
||||
@ColumnInfo(name = "album_name")
|
||||
val albumName: String,
|
||||
@ColumnInfo(name = "artist_id")
|
||||
val artistId: Int,
|
||||
val artistId: Long,
|
||||
@ColumnInfo(name = "artist_name")
|
||||
val artistName: String,
|
||||
val composer: String?,
|
||||
|
|
|
@ -9,7 +9,7 @@ interface PlaylistDao {
|
|||
suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long
|
||||
|
||||
@Query("UPDATE PlaylistEntity SET playlist_name = :name WHERE playlist_id = :playlistId")
|
||||
suspend fun renamePlaylist(playlistId: Int, name: String)
|
||||
suspend fun renamePlaylist(playlistId: Long, name: String)
|
||||
|
||||
@Query("SELECT * FROM PlaylistEntity WHERE playlist_name = :name")
|
||||
fun isPlaylistExists(name: String): List<PlaylistEntity>
|
||||
|
@ -18,10 +18,10 @@ interface PlaylistDao {
|
|||
suspend fun playlists(): List<PlaylistEntity>
|
||||
|
||||
@Query("DELETE FROM SongEntity WHERE playlist_creator_id = :playlistId")
|
||||
suspend fun deletePlaylistSongs(playlistId: Int)
|
||||
suspend fun deletePlaylistSongs(playlistId: Long)
|
||||
|
||||
@Query("DELETE FROM SongEntity WHERE playlist_creator_id = :playlistId AND id = :songId")
|
||||
suspend fun deleteSongFromPlaylist(playlistId: Int, songId: Int)
|
||||
suspend fun deleteSongFromPlaylist(playlistId: Long, songId: Long)
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM PlaylistEntity")
|
||||
|
@ -31,10 +31,10 @@ interface PlaylistDao {
|
|||
suspend fun insertSongsToPlaylist(songEntities: List<SongEntity>)
|
||||
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id = :playlistId AND id = :songId")
|
||||
suspend fun isSongExistsInPlaylist(playlistId: Int, songId: Int): List<SongEntity>
|
||||
suspend fun isSongExistsInPlaylist(playlistId: Long, songId: Long): List<SongEntity>
|
||||
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id = :playlistId")
|
||||
fun songsFromPlaylist(playlistId: Int): LiveData<List<SongEntity>>
|
||||
fun songsFromPlaylist(playlistId: Long): LiveData<List<SongEntity>>
|
||||
|
||||
@Delete
|
||||
suspend fun deletePlaylist(playlistEntity: PlaylistEntity)
|
||||
|
@ -47,10 +47,10 @@ interface PlaylistDao {
|
|||
|
||||
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id= :playlistId")
|
||||
fun favoritesSongsLiveData(playlistId: Int): LiveData<List<SongEntity>>
|
||||
fun favoritesSongsLiveData(playlistId: Long): LiveData<List<SongEntity>>
|
||||
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id= :playlistId")
|
||||
fun favoritesSongs(playlistId: Int): List<SongEntity>
|
||||
fun favoritesSongs(playlistId: Long): List<SongEntity>
|
||||
|
||||
|
||||
}
|
|
@ -9,10 +9,9 @@ import kotlinx.android.parcel.Parcelize
|
|||
@Entity
|
||||
@Parcelize
|
||||
class PlaylistEntity(
|
||||
@ColumnInfo(name = "playlist_name")
|
||||
val playlistName: String
|
||||
) : Parcelable {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "playlist_id")
|
||||
var playListId: Int = 0
|
||||
}
|
||||
val playListId: Long = 0,
|
||||
@ColumnInfo(name = "playlist_name")
|
||||
val playlistName: String
|
||||
) : Parcelable
|
|
@ -10,9 +10,12 @@ import kotlinx.android.parcel.Parcelize
|
|||
@Parcelize
|
||||
@Entity(indices = [Index(value = ["playlist_creator_id", "id"], unique = true)])
|
||||
class SongEntity(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "song_key")
|
||||
val songPrimaryKey: Long = 0L,
|
||||
@ColumnInfo(name = "playlist_creator_id")
|
||||
val playlistCreatorId: Int,
|
||||
val id: Int,
|
||||
val playlistCreatorId: Long,
|
||||
val id: Long,
|
||||
val title: String,
|
||||
@ColumnInfo(name = "track_number")
|
||||
val trackNumber: Int,
|
||||
|
@ -22,19 +25,15 @@ class SongEntity(
|
|||
@ColumnInfo(name = "date_modified")
|
||||
val dateModified: Long,
|
||||
@ColumnInfo(name = "album_id")
|
||||
val albumId: Int,
|
||||
val albumId: Long,
|
||||
@ColumnInfo(name = "album_name")
|
||||
val albumName: String,
|
||||
@ColumnInfo(name = "artist_id")
|
||||
val artistId: Int,
|
||||
val artistId: Long,
|
||||
@ColumnInfo(name = "artist_name")
|
||||
val artistName: String,
|
||||
val composer: String?,
|
||||
@ColumnInfo(name = "album_artist")
|
||||
val albumArtist: String?
|
||||
) : Parcelable {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "song_key")
|
||||
var songPrimaryKey: Long = 0
|
||||
}
|
||||
) : Parcelable
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ fun List<SongEntity>.toSongs(): List<Song> {
|
|||
}
|
||||
}
|
||||
|
||||
fun List<Song>.toSongs(playlistId: Int): List<SongEntity> {
|
||||
fun List<Song>.toSongs(playlistId: Long): List<SongEntity> {
|
||||
return map {
|
||||
it.toSongEntity(playlistId)
|
||||
}
|
||||
|
@ -16,75 +16,75 @@ fun List<Song>.toSongs(playlistId: Int): List<SongEntity> {
|
|||
|
||||
fun SongEntity.toSong(): Song {
|
||||
return Song(
|
||||
id,
|
||||
title,
|
||||
trackNumber,
|
||||
year,
|
||||
duration,
|
||||
data,
|
||||
dateModified,
|
||||
albumId,
|
||||
albumName,
|
||||
artistId,
|
||||
artistName,
|
||||
composer,
|
||||
albumArtist
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
fun PlayCountEntity.toSong(): Song {
|
||||
return Song(
|
||||
id,
|
||||
title,
|
||||
trackNumber,
|
||||
year,
|
||||
duration,
|
||||
data,
|
||||
dateModified,
|
||||
albumId,
|
||||
albumName,
|
||||
artistId,
|
||||
artistName,
|
||||
composer,
|
||||
albumArtist
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
fun HistoryEntity.toSong(): Song {
|
||||
return Song(
|
||||
id,
|
||||
title,
|
||||
trackNumber,
|
||||
year,
|
||||
duration,
|
||||
data,
|
||||
dateModified,
|
||||
albumId,
|
||||
albumName,
|
||||
artistId,
|
||||
artistName,
|
||||
composer,
|
||||
albumArtist
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
fun Song.toPlayCount(): PlayCountEntity {
|
||||
return PlayCountEntity(
|
||||
id,
|
||||
title,
|
||||
trackNumber,
|
||||
year,
|
||||
duration,
|
||||
data,
|
||||
dateModified,
|
||||
albumId,
|
||||
albumName,
|
||||
artistId,
|
||||
artistName,
|
||||
composer,
|
||||
albumArtist,
|
||||
System.currentTimeMillis(),
|
||||
1
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue