compare songs by their hashcode by default, not by id
This commit is contained in:
parent
1bd07a6c34
commit
baf1cb42dd
2 changed files with 3 additions and 9 deletions
|
@ -467,7 +467,7 @@ class MainActivity : SimpleActivity(), SongListListener {
|
|||
songs_playlist_empty_add_folder.beVisibleIf(songs.isEmpty())
|
||||
}
|
||||
|
||||
private fun getSongIndex(song: Song): Int = songs.indexOfFirstOrNull { it == song } ?: 0
|
||||
private fun getSongIndex(song: Song) = songs.indexOfFirstOrNull { it == song } ?: 0
|
||||
|
||||
private fun getSongsAdapter() = songs_list.adapter as? SongAdapter
|
||||
|
||||
|
@ -507,9 +507,9 @@ class MainActivity : SimpleActivity(), SongListListener {
|
|||
}
|
||||
|
||||
private fun markCurrentSong() {
|
||||
val newSongId = MusicService.mCurrSong?.id ?: -1L
|
||||
val newSong = MusicService.mCurrSong
|
||||
val cnt = songs.size - 1
|
||||
val songIndex = (0..cnt).firstOrNull { songs[it].id == newSongId }?.plus(0) ?: -1
|
||||
val songIndex = (0..cnt).firstOrNull { songs[it] == newSong } ?: -1
|
||||
getSongsAdapter()?.updateCurrentSongIndex(songIndex)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,12 +49,6 @@ data class Song(val id: Long, var title: String, var artist: String, var path: S
|
|||
return res
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean = when {
|
||||
this === other -> true
|
||||
other == null -> false
|
||||
else -> id == (other as Song).id
|
||||
}
|
||||
|
||||
fun getBubbleText() = when {
|
||||
sorting and SORT_BY_TITLE != 0 -> title
|
||||
sorting and SORT_BY_ARTIST != 0 -> artist
|
||||
|
|
Loading…
Reference in a new issue