diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-25 21:45:26 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2018-12-25 21:45:26 -0500 |
commit | f931e55d534e6162748f9fa888e7313cc2f0b619 (patch) | |
tree | 34ee7c82f49420d83ee44d77cace56cd8fbd3582 /kpref-activity/src | |
parent | d850474b0a82ee00d094990d9bd3392ae8cd9575 (diff) | |
download | kau-f931e55d534e6162748f9fa888e7313cc2f0b619.tar.gz kau-f931e55d534e6162748f9fa888e7313cc2f0b619.tar.bz2 kau-f931e55d534e6162748f9fa888e7313cc2f0b619.zip |
Use withContext instead of async
Diffstat (limited to 'kpref-activity/src')
-rw-r--r-- | kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt | 7 |
1 files changed, 4 insertions, 3 deletions
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) } |