Kotlin Coroutines the right way in Android

前端 未结 9 1121
醉酒成梦
醉酒成梦 2020-12-02 06:51

I\'m trying to update a list inside the adapter using async, I can see there is too much boilerplate.

Is it the right way to use Kotlin Coroutines?

can this

9条回答
  •  忘掉有多难
    2020-12-02 07:00

    We also have another option. if we use Anko library , then it looks like this

    doAsync { 
    
        // Call all operation  related to network or other ui blocking operations here.
        uiThread { 
            // perform all ui related operation here    
        }
    }
    

    Add dependency for Anko in your app gradle like this.

    implementation "org.jetbrains.anko:anko:0.10.5"
    

提交回复
热议问题