musikr: clarify added/modified timestamp apis
Clearly indicate their new millisecond nature.
This commit is contained in:
parent
c359048721
commit
ae6a0438be
10 changed files with 20 additions and 17 deletions
|
@ -128,7 +128,7 @@ class SongListFragment :
|
|||
|
||||
// Last added -> Format as date
|
||||
is Sort.Mode.ByDateAdded -> {
|
||||
val dateAddedMillis = song.dateAdded.secsToMs()
|
||||
val dateAddedMillis = song.addedMs.secsToMs()
|
||||
formatterSb.setLength(0)
|
||||
DateUtils.formatDateRange(
|
||||
context,
|
||||
|
|
|
@ -360,8 +360,8 @@ data class Sort(val mode: Mode, val direction: Direction) {
|
|||
override fun sortSongs(songs: MutableList<Song>, direction: Direction) {
|
||||
songs.sortBy { it.name }
|
||||
when (direction) {
|
||||
Direction.ASCENDING -> songs.sortBy { it.dateAdded }
|
||||
Direction.DESCENDING -> songs.sortByDescending { it.dateAdded }
|
||||
Direction.ASCENDING -> songs.sortBy { it.addedMs }
|
||||
Direction.DESCENDING -> songs.sortByDescending { it.addedMs }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -272,10 +272,13 @@ interface Song : Music {
|
|||
val sampleRateHz: Int
|
||||
/** The ReplayGain adjustment to apply during playback. */
|
||||
val replayGainAdjustment: ReplayGainAdjustment
|
||||
/** The date last modified the audio file was last modified, as a unix epoch timestamp. */
|
||||
val lastModified: Long
|
||||
/** The date the audio file was added to the device, as a unix epoch timestamp. */
|
||||
val dateAdded: Long
|
||||
/**
|
||||
* The date last modified the audio file was last modified, in milliseconds since the unix
|
||||
* epoch.
|
||||
*/
|
||||
val modifiedMs: Long
|
||||
/** The time the audio file was added to the device, in milliseconds since the unix epoch. */
|
||||
val addedMs: Long
|
||||
/** Useful information to quickly obtain the album cover. */
|
||||
val cover: Cover?
|
||||
/**
|
||||
|
|
|
@ -174,7 +174,7 @@ internal data class CachedSong(
|
|||
fun fromRawSong(rawSong: RawSong) =
|
||||
CachedSong(
|
||||
uri = rawSong.file.uri.toString(),
|
||||
modifiedMs = rawSong.file.lastModified,
|
||||
modifiedMs = rawSong.file.modifiedMs,
|
||||
addedMs = rawSong.addedMs,
|
||||
// Should be strictly monotonic so we don't prune this
|
||||
// by accident later.
|
||||
|
|
|
@ -55,7 +55,7 @@ private class VisibleStoredCache(private val visibleDao: VisibleCacheDao, writeD
|
|||
BaseStoredCache(writeDao) {
|
||||
override suspend fun read(file: DeviceFile, covers: Covers): CacheResult {
|
||||
val song = visibleDao.selectSong(file.uri.toString()) ?: return CacheResult.Miss(file, null)
|
||||
if (song.modifiedMs != file.lastModified) {
|
||||
if (song.modifiedMs != file.modifiedMs) {
|
||||
// We *found* this file earlier, but it's out of date.
|
||||
// Send back it with the timestamp so it will be re-used.
|
||||
// The touch timestamp will be updated on write.
|
||||
|
|
|
@ -25,5 +25,5 @@ internal data class DeviceFile(
|
|||
val mimeType: String,
|
||||
val path: Path,
|
||||
val size: Long,
|
||||
val lastModified: Long
|
||||
val modifiedMs: Long
|
||||
)
|
||||
|
|
|
@ -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.dateAdded }
|
||||
override val dateAdded = 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()) }
|
||||
|
|
|
@ -55,8 +55,8 @@ internal class SongImpl(private val handle: SongCore) : Song {
|
|||
override val bitrateKbps = preSong.bitrateKbps
|
||||
override val sampleRateHz = preSong.sampleRateHz
|
||||
override val replayGainAdjustment = preSong.replayGainAdjustment
|
||||
override val lastModified = preSong.lastModified
|
||||
override val dateAdded = preSong.dateAdded
|
||||
override val modifiedMs = preSong.modifiedMs
|
||||
override val addedMs = preSong.addedMs
|
||||
override val cover = preSong.cover
|
||||
override val album: Album
|
||||
get() = handle.resolveAlbum()
|
||||
|
|
|
@ -46,8 +46,8 @@ internal data class PreSong(
|
|||
val bitrateKbps: Int,
|
||||
val sampleRateHz: Int,
|
||||
val replayGainAdjustment: ReplayGainAdjustment,
|
||||
val lastModified: Long,
|
||||
val dateAdded: Long,
|
||||
val modifiedMs: Long,
|
||||
val addedMs: Long,
|
||||
val cover: Cover?,
|
||||
val preAlbum: PreAlbum,
|
||||
val preArtists: List<PreArtist>,
|
||||
|
|
|
@ -64,8 +64,8 @@ private class TagInterpreterImpl(private val interpretation: Interpretation) : T
|
|||
path = song.file.path,
|
||||
size = song.file.size,
|
||||
format = Format.infer(song.file.mimeType, song.properties.mimeType),
|
||||
lastModified = song.file.lastModified,
|
||||
dateAdded = song.addedMs,
|
||||
modifiedMs = song.file.modifiedMs,
|
||||
addedMs = song.addedMs,
|
||||
musicBrainzId = song.tags.musicBrainzId?.toUuidOrNull(),
|
||||
name = interpretation.naming.name(song.tags.name, song.tags.sortName),
|
||||
rawName = song.tags.name,
|
||||
|
|
Loading…
Reference in a new issue