Fix jumping downloads in Download view

This commit is contained in:
tzugen 2021-11-14 23:31:01 +01:00
parent 19d014709f
commit 7a2dbf65d9
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
2 changed files with 6 additions and 9 deletions

View File

@ -219,17 +219,15 @@ class TrackViewHolder(val view: View, var adapter: MultiTypeDiffAdapter<Identifi
} }
} }
fun updateDownloadStatus(downloadFile: DownloadFile) { fun updateDownloadStatus(downloadFile: DownloadFile) {
if (downloadFile.isWorkDone) { if (downloadFile.isWorkDone) {
val saved = downloadFile.isSaved
val newLeftImageType = val newLeftImageType =
if (downloadFile.isSaved) ImageType.Pin else ImageType.Downloaded if (saved) ImageType.Pin else ImageType.Downloaded
if (leftImageType != newLeftImageType) { if (leftImageType != newLeftImageType) {
leftImage = if (downloadFile.isSaved) { leftImage = if (saved) imageHelper.pinImage else imageHelper.downloadedImage
imageHelper.pinImage
} else {
imageHelper.downloadedImage
}
leftImageType = newLeftImageType leftImageType = newLeftImageType
} }
} else { } else {

View File

@ -381,9 +381,8 @@ class Downloader(
@Synchronized @Synchronized
fun downloadBackground(songs: List<MusicDirectory.Entry>, save: Boolean) { fun downloadBackground(songs: List<MusicDirectory.Entry>, save: Boolean) {
// Because of the priority handling we add the songs in the reverse order they // By using the counter we ensure that the songs are added in the correct order
// were requested, then it is correct in the end. for (song in songs) {
for (song in songs.asReversed()) {
val file = song.getDownloadFile() val file = song.getDownloadFile()
file.shouldSave = save file.shouldSave = save
file.priority = backgroundPriorityCounter++ file.priority = backgroundPriorityCounter++