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