PlayerAndroid/app/src/main/java/code/name/monkey/retromusic/model/Song.kt

75 lines
2.3 KiB
Kotlin
Raw Normal View History

2019-03-04 03:55:09 +00:00
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.model
import android.os.Parcelable
2020-04-26 09:55:00 +00:00
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
2020-04-25 07:27:05 +00:00
import code.name.monkey.retromusic.room.SongEntity
2019-03-04 03:55:09 +00:00
import kotlinx.android.parcel.Parcelize
@Parcelize
2020-04-26 09:55:00 +00:00
@Entity(tableName = "playing_queue")
2019-11-13 13:07:44 +00:00
open class Song(
2020-04-26 09:55:00 +00:00
@PrimaryKey val id: Int,
@ColumnInfo(name = "title") val title: String,
@ColumnInfo(name = "track_number") val trackNumber: Int,
@ColumnInfo(name = "year") val year: Int,
@ColumnInfo(name = "duration") val duration: Long,
@ColumnInfo(name = "data") val data: String,
@ColumnInfo(name = "date_modified") val dateModified: Long,
@ColumnInfo(name = "album_id") val albumId: Int,
@ColumnInfo(name = "album_name") val albumName: String,
@ColumnInfo(name = "artist_id") val artistId: Int,
@ColumnInfo(name = "artist_name") val artistName: String,
@ColumnInfo(name = "composer") val composer: String?
2019-11-13 13:07:44 +00:00
) : Parcelable {
2019-03-04 03:55:09 +00:00
companion object {
2020-04-25 07:27:05 +00:00
fun toSongEntity(song: Song): SongEntity {
return SongEntity(
song.id,
song.title,
song.trackNumber,
song.year,
song.duration,
song.data,
song.dateModified,
song.albumId,
song.albumName,
song.artistId,
song.artistName,
song.composer
)
}
2019-03-04 03:55:09 +00:00
@JvmStatic
2019-11-13 13:07:44 +00:00
val emptySong = Song(
2020-01-29 17:25:43 +00:00
-1,
"",
-1,
-1,
-1,
"",
-1,
-1,
"",
-1,
"",
""
2019-11-13 13:07:44 +00:00
)
2019-03-04 03:55:09 +00:00
}
}