Concurrent Map Exception Fix

This commit is contained in:
shabinder 2021-09-27 00:26:05 +05:30
parent eb7c6966d7
commit 98433bb961

View File

@ -174,12 +174,10 @@ internal class SpotiFlyerListStoreProvider(dependencies: SpotiFlyerList.Dependen
} }
} }
private fun List<TrackDetails>.updateTracksStatuses(map: HashMap<String, DownloadStatus>): List<TrackDetails> { private fun List<TrackDetails>.updateTracksStatuses(map: Map<String, DownloadStatus>): List<TrackDetails> {
val titleList = this.map { it.title } val updatedList = ArrayList(this)
val updatedList = mutableListOf<TrackDetails>().also { it.addAll(this) } LinkedHashMap(map).forEach { newTrack ->
indexOfFirst { it.title == newTrack.key }.let { position ->
for (newTrack in map) {
titleList.indexOf(newTrack.key).let { position ->
if (position != -1) { if (position != -1) {
updatedList.getOrNull(position)?.copy( updatedList.getOrNull(position)?.copy(
downloaded = newTrack.value, downloaded = newTrack.value,