Closed naveensingh closed 1 year ago
cannot compile, tracksadapter 282 is missing sorting parameter
I see, my bad. My IDE is probably malfunctioning, it compiled successfully and I didn't even get any crashes. I'm checking it now
Check it now, please. You can reproduce the crash on 5.17.1 using this:
private fun testSorting() {
val sortMethods = listOf(PLAYER_SORT_BY_DATE_ADDED, PLAYER_SORT_BY_TRACK_ID, PLAYER_SORT_BY_ARTIST_TITLE, PLAYER_SORT_BY_TITLE, PLAYER_SORT_BY_DURATION)
ensureBackgroundThread {
repeat(25) {
sortMethods.shuffled().forEach { sorting ->
ensureBackgroundThread {
config.trackSorting = sorting
Thread.sleep((0L..2L).random())
try {
applicationContext.audioHelper.getAllTracks()
} catch (e: Exception) {
throw Exception("failed to sort by ${sorting}, error: ${e.message}")
}
}
}
}
}
}
ok thanks, Ill trust you on this one :)
Changes:
NullPointerException
inMusicService.updateUI()
Exception java.lang.IllegalArgumentException: cannot start a load for a destroyed activity
sorting
variable in data classes because the value can be modified while a sort is in progress leading toException java.lang.IllegalArgumentException: Comparison method violates its general contract!
. Hence,Artist
,Album
,Track
,Folder
,Playlist
, andGenre
classes no longer implement theComparable
interface, and the comparator logic was moved to staticgetComparator(sorting)
methods. As explained here, this error is thrown because the comparator is not transitive but in our case, that only happens because thesorting
variable was modified concurrently.