在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):bennyhuo/kotlin-coroutines-android开源软件地址(OpenSource Url):https://github.com/bennyhuo/kotlin-coroutines-android开源编程语言(OpenSource Language):Kotlin 96.0%开源软件介绍(OpenSource Introduction):kotlin-coroutines-androidUseful extensions for coroutines. Provide easier MainScope integration and auto disposable Job according to the view attached state. AutoDisposableInspired by AutoDispose, auto cancel the job according to the attach state of corresponding view. UsageAdd dependency in gradle:
Use In the sample below, val anotherButton = Button(this)
parentView.addView(anotherButton, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
anotherButton.setOnClickListener {
GlobalScope.launch(Dispatchers.Main) {
log(1)
parentView.removeView(anotherButton)
delay(1000)
log(2)
}.asAutoDisposable(it)
} MainScopeVersions see ChangeLog. Supplement for kotlinx.coroutines, providing useful extensions for android Views and easier way to integrate. An instance of UsageAdd dependency in gradle:
Initialize this library in your customized class App : Application() {
override fun onCreate() {
super.onCreate()
MainScope.setUp(this)
}
} Implement class MainActivity : AppCompatActivity(), AppCompatScoped, RecyclerViewScoped {
...
} To access the class MainActivity : AppCompatActivity(), BasicScoped {
override fun onCreate(savedInstanceState: Bundle?) {
...
mainScope.launch {
log("Hey!")
}
...
}
} It is also easy to launch multi-coroutines with the ...
withMainScope {
launch {
...
}
async(Dispatchers.IO) {
...
}
}
... Most of the listeners borrowed from Anko are equipped with ...
button.onClick {
log(1)
delay(1000)
log(2)
textView.text = "Hello Coroutine!"
}
...
About FragmentSince
IssuePlease feel free to issue and pull request. License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论