diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-24 20:05:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-24 20:05:06 -0500 |
commit | 8447b1ae8ce89b3f1bbe79dbae8847d901831c12 (patch) | |
tree | ce516950e452581766e905ead32970d891bb46f6 /about/src/main/kotlin | |
parent | 701b94ab09ff53aca682fac6c4ef5364566339be (diff) | |
download | kau-8447b1ae8ce89b3f1bbe79dbae8847d901831c12.tar.gz kau-8447b1ae8ce89b3f1bbe79dbae8847d901831c12.tar.bz2 kau-8447b1ae8ce89b3f1bbe79dbae8847d901831c12.zip |
Enhancement/coroutines (#180)
* Add coroutine dependency
* Add coroutines to kprefactivity
* Change base job to supervisor
* Update coroutines for faq
* Update changelog
* Use preloading in media picker core
* Make test logging internal
* Remove anko
Diffstat (limited to 'about/src/main/kotlin')
-rw-r--r-- | about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt | 24 |
1 files changed, 14 insertions, 10 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 35c1322..f77bcf2 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt @@ -35,8 +35,9 @@ import ca.allanwang.kau.utils.withMarginDecoration import ca.allanwang.kau.xml.kauParseFaq import com.mikepenz.aboutlibraries.Libs import com.mikepenz.fastadapter.IItem -import org.jetbrains.anko.doAsync -import org.jetbrains.anko.uiThread +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.launch /** * Created by Allan Wang on 2017-08-02. @@ -174,13 +175,16 @@ open class AboutPanelLibs : AboutPanelRecycler() { } override fun loadItems(activity: AboutActivityBase, position: Int) { - doAsync { - with(activity) { - items = - getLibraries(if (rClass == null) Libs(activity) else Libs(this, Libs.toStringArray(rClass.fields))) - .map(::LibraryIItem) + with(activity) { + launch { + items = async { + getLibraries( + if (rClass == null) Libs(activity) + else Libs(activity, Libs.toStringArray(rClass.fields)) + ).map(::LibraryIItem) + }.await() if (pageStatus[position] == 1) - uiThread { addItems(activity, position) } + addItems(activity, position) } } } @@ -202,8 +206,8 @@ open class AboutPanelFaqs : AboutPanelRecycler() { override fun loadItems(activity: AboutActivityBase, position: Int) { with(activity) { - kauParseFaq(configs.faqXmlRes, configs.faqParseNewLine) { - items = it.map(::FaqIItem) + launch { + items = async { kauParseFaq(configs.faqXmlRes, configs.faqParseNewLine) }.await().map(::FaqIItem) if (pageStatus[position] == 1) addItems(activity, position) } |