Initial commit

This commit is contained in:
vfsfitvnm
2022-06-02 18:59:18 +02:00
commit 1e673ad582
160 changed files with 10800 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package it.vfsfitvnm.vimusic.models
import androidx.room.*
@Entity
data class Song(
@PrimaryKey val id: String,
val title: String,
val albumInfoId: Long?,
val durationText: String,
val thumbnailUrl: String?,
val likedAt: Long? = null,
val totalPlayTimeMs: Long = 0
) {
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"
}
}
fun toggleLike(): Song {
return copy(
likedAt = if (likedAt == null) System.currentTimeMillis() else null
)
}
}