From f931e55d534e6162748f9fa888e7313cc2f0b619 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 25 Dec 2018 21:45:26 -0500 Subject: Use withContext instead of async --- .../main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'kpref-activity') diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt index 450bc6e..edaf347 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt @@ -33,8 +33,9 @@ import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.withLinearAdapter import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter import kotlinx.android.synthetic.main.kau_pref_activity.* -import kotlinx.coroutines.async +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import java.util.Stack abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { @@ -105,12 +106,12 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { first: Boolean ) { launch { - val items = async { + val items = withContext(Dispatchers.Default) { val items = KPrefAdapterBuilder(globalOptions) builder(items) kprefStack.push(toolbarTitleRes to items.list) items.list - }.await() + } kau_recycler.itemAnimator = if (animate && !first) recyclerAnimatorNext else null show(toolbarTitleRes, items) } -- cgit v1.2.3