diff --git a/app/src/main/java/com/github/apognu/otter/activities/DownloadsActivity.kt b/app/src/main/java/com/github/apognu/otter/activities/DownloadsActivity.kt index e580260..80a96cf 100644 --- a/app/src/main/java/com/github/apognu/otter/activities/DownloadsActivity.kt +++ b/app/src/main/java/com/github/apognu/otter/activities/DownloadsActivity.kt @@ -64,9 +64,9 @@ class DownloadsActivity : AppCompatActivity() { } private suspend fun refreshTrack(download: Download) { - if (download.state == Download.STATE_COMPLETED) { - download.getMetadata()?.let { info -> - adapter.downloads.withIndex().associate { it.value to it.index }.filter { it.key.id == info.id }.toList().getOrNull(0)?.let { match -> + download.getMetadata()?.let { info -> + adapter.downloads.withIndex().associate { it.value to it.index }.filter { it.key.id == info.id }.toList().getOrNull(0)?.let { match -> + if (download.state != info.download?.state) { withContext(Main) { adapter.downloads[match.second] = info.apply { this.download = download diff --git a/app/src/main/java/com/github/apognu/otter/adapters/DownloadsAdapter.kt b/app/src/main/java/com/github/apognu/otter/adapters/DownloadsAdapter.kt index e5ef6af..7bb76a8 100644 --- a/app/src/main/java/com/github/apognu/otter/adapters/DownloadsAdapter.kt +++ b/app/src/main/java/com/github/apognu/otter/adapters/DownloadsAdapter.kt @@ -52,9 +52,14 @@ class DownloadsAdapter(private val context: Context, private val listener: OnDow false -> { holder.progress.visibility = View.VISIBLE holder.toggle.visibility = View.VISIBLE + holder.progress.isIndeterminate = false holder.progress.progress = state.percentDownloaded.toInt() when (state.state) { + Download.STATE_QUEUED -> { + holder.progress.isIndeterminate = true + } + Download.STATE_REMOVING -> { holder.progress.visibility = View.GONE holder.toggle.visibility = View.GONE @@ -69,7 +74,7 @@ class DownloadsAdapter(private val context: Context, private val listener: OnDow holder.toggle.setOnClickListener { when (state.state) { - Download.STATE_DOWNLOADING -> DownloadService.sendSetStopReason(context, PinService::class.java, download.contentId, 1, false) + Download.STATE_QUEUED, Download.STATE_DOWNLOADING -> DownloadService.sendSetStopReason(context, PinService::class.java, download.contentId, 1, false) Download.STATE_FAILED -> { Track(download.id, download.title, Artist(0, download.artist, listOf()),Album(0, Album.Artist(""), "", Covers("")), 0, listOf(Track.Upload(download.contentId, 0, 0))).also {