musikr: clarify album added timestamp api

Same reasons, should be milliseconds
This commit is contained in:
Alexander Capehart 2025-01-09 19:31:32 -07:00
parent ae6a0438be
commit e6b326a571
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
4 changed files with 6 additions and 7 deletions

View file

@ -43,7 +43,6 @@ import org.oxycblt.auxio.music.MusicViewModel
import org.oxycblt.auxio.music.resolve import org.oxycblt.auxio.music.resolve
import org.oxycblt.auxio.playback.PlaybackViewModel import org.oxycblt.auxio.playback.PlaybackViewModel
import org.oxycblt.auxio.playback.formatDurationMs import org.oxycblt.auxio.playback.formatDurationMs
import org.oxycblt.auxio.playback.secsToMs
import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.collectImmediately
import org.oxycblt.musikr.Album import org.oxycblt.musikr.Album
import org.oxycblt.musikr.Music import org.oxycblt.musikr.Music
@ -128,7 +127,7 @@ class AlbumListFragment :
// Last added -> Format as date // Last added -> Format as date
is Sort.Mode.ByDateAdded -> { is Sort.Mode.ByDateAdded -> {
val dateAddedMillis = album.dateAdded.secsToMs() val dateAddedMillis = album.addedMs
formatterSb.setLength(0) formatterSb.setLength(0)
DateUtils.formatDateRange( DateUtils.formatDateRange(
context, context,

View file

@ -368,8 +368,8 @@ data class Sort(val mode: Mode, val direction: Direction) {
override fun sortAlbums(albums: MutableList<Album>, direction: Direction) { override fun sortAlbums(albums: MutableList<Album>, direction: Direction) {
albums.sortBy { it.name } albums.sortBy { it.name }
when (direction) { when (direction) {
Direction.ASCENDING -> albums.sortBy { it.dateAdded } Direction.ASCENDING -> albums.sortBy { it.addedMs }
Direction.DESCENDING -> albums.sortByDescending { it.dateAdded } Direction.DESCENDING -> albums.sortByDescending { it.addedMs }
} }
} }
} }

View file

@ -317,8 +317,8 @@ interface Album : MusicParent {
val covers: CoverCollection val covers: CoverCollection
/** The duration of all songs in the album, in milliseconds. */ /** The duration of all songs in the album, in milliseconds. */
val durationMs: Long val durationMs: Long
/** The earliest date a song in this album was added, as a unix epoch timestamp. */ /** The earliest date a song in this album was added, in milliseconds since the unix epoch. */
val dateAdded: Long val addedMs: Long
/** /**
* The parent [Artist]s of this [Album]. Is often one, but there can be multiple if more than * The parent [Artist]s of this [Album]. Is often one, but there can be multiple if more than
* one [Artist] name was specified in the metadata of the [Song]'s. Unlike [Song], album artists * one [Artist] name was specified in the metadata of the [Song]'s. Unlike [Song], album artists

View file

@ -55,7 +55,7 @@ class AlbumImpl internal constructor(private val core: AlbumCore) : Album {
override val name = preAlbum.name override val name = preAlbum.name
override val releaseType = preAlbum.releaseType override val releaseType = preAlbum.releaseType
override val durationMs = core.songs.sumOf { it.durationMs } override val durationMs = core.songs.sumOf { it.durationMs }
override val dateAdded = core.songs.minOf { it.addedMs } override val addedMs = core.songs.minOf { it.addedMs }
override val covers = CoverCollection.from(core.songs.mapNotNull { it.cover }) override val covers = CoverCollection.from(core.songs.mapNotNull { it.cover })
override val dates: Date.Range? = override val dates: Date.Range? =
core.songs.mapNotNull { it.date }.ifEmpty { null }?.run { Date.Range(min(), max()) } core.songs.mapNotNull { it.date }.ifEmpty { null }?.run { Date.Range(min(), max()) }