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) {
if (downloadFile.isWorkDone) {
val saved = downloadFile.isSaved
val newLeftImageType =
if (downloadFile.isSaved) ImageType.Pin else ImageType.Downloaded
if (saved) ImageType.Pin else ImageType.Downloaded
if (leftImageType != newLeftImageType) {
leftImage = if (downloadFile.isSaved) {
imageHelper.pinImage
} else {
imageHelper.downloadedImage
}
leftImage = if (saved) imageHelper.pinImage else imageHelper.downloadedImage
leftImageType = newLeftImageType
}
} else {

View File

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