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

95 lines
2.2 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-08-21 14:19:15 +00:00
import code.name.monkey.retromusic.db.HistoryEntity
2020-08-20 10:01:22 +00:00
import code.name.monkey.retromusic.db.SongEntity
2019-03-04 03:55:09 +00:00
import kotlinx.android.parcel.Parcelize
@Parcelize
2019-11-13 13:07:44 +00:00
open class Song(
2020-05-03 19:24:11 +00:00
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,
2020-08-11 18:29:44 +00:00
val composer: String?,
val albumArtist: String?
2019-11-13 13:07:44 +00:00
) : Parcelable {
2020-08-21 14:19:15 +00:00
fun toHistoryEntity(timePlayed: Long): HistoryEntity {
return HistoryEntity(
id,
title,
trackNumber,
year,
duration,
data,
dateModified,
albumId,
albumName,
artistId,
artistName,
composer,
albumArtist,
timePlayed
)
}
2020-08-20 10:01:22 +00:00
fun toSongEntity(playListId: Int): SongEntity {
return SongEntity(
playListId,
id,
title,
trackNumber,
year,
duration,
data,
dateModified,
albumId,
albumName,
artistId,
artistName,
composer,
albumArtist
)
}
2019-03-04 03:55:09 +00:00
companion object {
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,
"",
2020-08-11 18:29:44 +00:00
"",
2020-01-29 17:25:43 +00:00
""
2019-11-13 13:07:44 +00:00
)
2019-03-04 03:55:09 +00:00
}
}