UpdatesFragment: Check if downloads are running instead of finished
Update all button otherwise shows cancel on first run Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -10,5 +10,6 @@ enum class DownloadStatus {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val finished = listOf(FAILED, CANCELLED, COMPLETED)
|
val finished = listOf(FAILED, CANCELLED, COMPLETED)
|
||||||
|
val running = listOf(QUEUED, DOWNLOADING)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ data class Download(
|
|||||||
val sharedLibs: List<SharedLib>
|
val sharedLibs: List<SharedLib>
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
val isFinished get() = downloadStatus in DownloadStatus.finished
|
val isFinished get() = downloadStatus in DownloadStatus.finished
|
||||||
|
val isRunning get() = downloadStatus in DownloadStatus.running
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromApp(app: App): Download {
|
fun fromApp(app: App): Download {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
|
|||||||
}.collectLatest { map ->
|
}.collectLatest { map ->
|
||||||
updateController(map)
|
updateController(map)
|
||||||
binding.swipeRefreshLayout.isRefreshing = false
|
binding.swipeRefreshLayout.isRefreshing = false
|
||||||
viewModel.updateAllEnqueued = map?.values?.all { it?.isFinished != true } ?: false
|
viewModel.updateAllEnqueued = map?.values?.all { it?.isRunning == true } ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user