Sunday, March 21, 2021

Some beautiful examples of Kotlin

 1. UI Callbacks

var uirefreshListener: (()->Unit)? = null
this.uirefreshListener={
showPostLoginUI()
}
@JvmStatic
fun addCustomerPremiumInfo(context: Context, customer_id: Int, callbackUI: (() -> Unit)?) {
}

2. Static fields and methods
companion object {
@JvmStatic
fun syncCustomerData(context: Context, name: String, email: String) {
}

3. Async and runonMainUI and co-routines

GlobalScope.async {
val ackPurchaseResult = withContext(Dispatchers.IO) {
billingClient.acknowledgePurchase(acknowledgePurchaseParams.build(),acknowledgePurchaseResponseListener)
}
}


    

No comments:

Post a Comment