aboutsummaryrefslogtreecommitdiff
path: root/about/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-25 21:45:26 -0500
committerAllan Wang <me@allanwang.ca>2018-12-25 21:45:26 -0500
commitf931e55d534e6162748f9fa888e7313cc2f0b619 (patch)
tree34ee7c82f49420d83ee44d77cace56cd8fbd3582 /about/src/main/kotlin
parentd850474b0a82ee00d094990d9bd3392ae8cd9575 (diff)
downloadkau-f931e55d534e6162748f9fa888e7313cc2f0b619.tar.gz
kau-f931e55d534e6162748f9fa888e7313cc2f0b619.tar.bz2
kau-f931e55d534e6162748f9fa888e7313cc2f0b619.zip
Use withContext instead of async
Diffstat (limited to 'about/src/main/kotlin')
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt13
1 files changed, 9 insertions, 4 deletions
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
index f77bcf2..924a771 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
@@ -36,8 +36,8 @@ import ca.allanwang.kau.xml.kauParseFaq
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.fastadapter.IItem
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.async
import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
/**
* Created by Allan Wang on 2017-08-02.
@@ -177,12 +177,12 @@ open class AboutPanelLibs : AboutPanelRecycler() {
override fun loadItems(activity: AboutActivityBase, position: Int) {
with(activity) {
launch {
- items = async {
+ items = withContext(Dispatchers.Default) {
getLibraries(
if (rClass == null) Libs(activity)
else Libs(activity, Libs.toStringArray(rClass.fields))
).map(::LibraryIItem)
- }.await()
+ }
if (pageStatus[position] == 1)
addItems(activity, position)
}
@@ -207,7 +207,12 @@ open class AboutPanelFaqs : AboutPanelRecycler() {
override fun loadItems(activity: AboutActivityBase, position: Int) {
with(activity) {
launch {
- items = async { kauParseFaq(configs.faqXmlRes, configs.faqParseNewLine) }.await().map(::FaqIItem)
+ items = withContext(Dispatchers.IO) {
+ kauParseFaq(
+ configs.faqXmlRes,
+ configs.faqParseNewLine
+ )
+ }.map(::FaqIItem)
if (pageStatus[position] == 1)
addItems(activity, position)
}