From fbdfa40300e009a79e81658aa0aa7746fe303d8f Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 5 Oct 2020 14:09:11 -0300 Subject: [PATCH] Load app status data off the UI thread Previously, the data was loaded on the UI thread which produced a visible freeze after clicking "App backup status". --- .../com/stevesoltys/seedvault/settings/SettingsViewModel.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt index 7332d2b7..e538b208 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -37,6 +37,7 @@ import com.stevesoltys.seedvault.transport.requestBackup import com.stevesoltys.seedvault.ui.RequireProvisioningViewModel import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.getAppName +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import java.util.Locale @@ -85,7 +86,7 @@ internal class SettingsViewModel( } } - private fun getAppStatusResult(): LiveData = liveData { + private fun getAppStatusResult(): LiveData = liveData(Dispatchers.Default) { val pm = app.packageManager val locale = Locale.getDefault() val list = packageService.userApps.map {