From eaa1848f9731f4e900f5356d1a05a98b3d2d03f4 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sun, 9 Jan 2022 14:59:30 +0100 Subject: [PATCH] LicenseScreen: load license text in worker thread --- .../mm20/launcher2/ui/settings/license/LicenseScreenVM.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/settings/license/LicenseScreenVM.kt b/ui/src/main/java/de/mm20/launcher2/ui/settings/license/LicenseScreenVM.kt index 6bf7a2bb..cf6118cf 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/settings/license/LicenseScreenVM.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/settings/license/LicenseScreenVM.kt @@ -4,11 +4,15 @@ import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.liveData import de.mm20.launcher2.licenses.OpenSourceLibrary +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext class LicenseScreenVM(private val context: Application) : AndroidViewModel(context) { fun getLicenseText(library: OpenSourceLibrary) = liveData { - val text = context.resources.openRawResource(library.licenseText).reader() - .readText() + val text = withContext(Dispatchers.IO) { + context.resources.openRawResource(library.licenseText).reader() + .readText() + } emit(text) } } \ No newline at end of file