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

95 lines
2.2 KiB
Kotlin

/*
* 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
import code.name.monkey.retromusic.db.HistoryEntity
import code.name.monkey.retromusic.db.SongEntity
import kotlinx.android.parcel.Parcelize
@Parcelize
open class Song(
val id: Int,
val title: String,
val trackNumber: Int,
val year: Int,
val duration: Long,
val data: String,
val dateModified: Long,
val albumId: Int,
val albumName: String,
val artistId: Int,
val artistName: String,
val composer: String?,
val albumArtist: String?
) : Parcelable {
fun toHistoryEntity(timePlayed: Long): HistoryEntity {
return HistoryEntity(
id,
title,
trackNumber,
year,
duration,
data,
dateModified,
albumId,
albumName,
artistId,
artistName,
composer,
albumArtist,
timePlayed
)
}
fun toSongEntity(playListId: Int): SongEntity {
return SongEntity(
playListId,
id,
title,
trackNumber,
year,
duration,
data,
dateModified,
albumId,
albumName,
artistId,
artistName,
composer,
albumArtist
)
}
companion object {
@JvmStatic
val emptySong = Song(
-1,
"",
-1,
-1,
-1,
"",
-1,
-1,
"",
-1,
"",
"",
""
)
}
}