Skip to content

Commit

Permalink
musikr: clarify album added timestamp api
Browse files Browse the repository at this point in the history
Same reasons, should be milliseconds
  • Loading branch information
OxygenCobalt committed Jan 10, 2025
1 parent ae6a043 commit e6b326a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import org.oxycblt.auxio.music.MusicViewModel
import org.oxycblt.auxio.music.resolve
import org.oxycblt.auxio.playback.PlaybackViewModel
import org.oxycblt.auxio.playback.formatDurationMs
import org.oxycblt.auxio.playback.secsToMs
import org.oxycblt.auxio.util.collectImmediately
import org.oxycblt.musikr.Album
import org.oxycblt.musikr.Music
Expand Down Expand Up @@ -128,7 +127,7 @@ class AlbumListFragment :

// Last added -> Format as date
is Sort.Mode.ByDateAdded -> {
val dateAddedMillis = album.dateAdded.secsToMs()
val dateAddedMillis = album.addedMs
formatterSb.setLength(0)
DateUtils.formatDateRange(
context,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/oxycblt/auxio/list/sort/Sort.kt
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ data class Sort(val mode: Mode, val direction: Direction) {
override fun sortAlbums(albums: MutableList<Album>, direction: Direction) {
albums.sortBy { it.name }
when (direction) {
Direction.ASCENDING -> albums.sortBy { it.dateAdded }
Direction.DESCENDING -> albums.sortByDescending { it.dateAdded }
Direction.ASCENDING -> albums.sortBy { it.addedMs }
Direction.DESCENDING -> albums.sortByDescending { it.addedMs }
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions musikr/src/main/java/org/oxycblt/musikr/Music.kt
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ interface Album : MusicParent {
val covers: CoverCollection
/** The duration of all songs in the album, in milliseconds. */
val durationMs: Long
/** The earliest date a song in this album was added, as a unix epoch timestamp. */
val dateAdded: Long
/** The earliest date a song in this album was added, in milliseconds since the unix epoch. */
val addedMs: Long
/**
* 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
Expand Down
2 changes: 1 addition & 1 deletion musikr/src/main/java/org/oxycblt/musikr/model/AlbumImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AlbumImpl internal constructor(private val core: AlbumCore) : Album {
override val name = preAlbum.name
override val releaseType = preAlbum.releaseType
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 dates: Date.Range? =
core.songs.mapNotNull { it.date }.ifEmpty { null }?.run { Date.Range(min(), max()) }
Expand Down

0 comments on commit e6b326a

Please sign in to comment.