Do not return unused fields in DetailedSong
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package it.vfsfitvnm.vimusic.models
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Junction
|
||||
import androidx.room.Relation
|
||||
|
||||
open class DetailedSong(
|
||||
@Embedded val song: Song,
|
||||
val id: String,
|
||||
val title: String,
|
||||
val artistsText: String? = null,
|
||||
val durationText: String,
|
||||
val thumbnailUrl: String?,
|
||||
val likedAt: Long? = null,
|
||||
val totalPlayTimeMs: Long = 0,
|
||||
@Relation(
|
||||
entity = SongAlbumMap::class,
|
||||
entityColumn = "songId",
|
||||
@@ -24,4 +29,17 @@ open class DetailedSong(
|
||||
)
|
||||
)
|
||||
val artists: List<Artist>?
|
||||
)
|
||||
) {
|
||||
val formattedTotalPlayTime: String
|
||||
get() {
|
||||
val seconds = totalPlayTimeMs / 1000
|
||||
|
||||
val hours = seconds / 3600
|
||||
|
||||
return when {
|
||||
hours == 0L -> "${seconds / 60}m"
|
||||
hours < 24L -> "${hours}h"
|
||||
else -> "${hours / 24}d"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user