ThreadToggle - VerstSiu/kotlin_extension GitHub Wiki
API List
com.ijoic.ktx.util
object AsyncLooper {
/*
* Main thread handler
*/
val handler: Handler
/*
* toggle thread
*/
fun main(action: () -> Unit)
}
Usage
execute actions at main thread:
// called from any thread
AsyncLooper.main { showToast("Hello world!") }
use handler to make thread toggle:
// called from any thread
AsyncLooper.handler.postDelayed({
showToast("message delayed")
}, 2000)