Passing lambda instead of interface

As @zsmb13 said, SAM conversions are only supported for Java interfaces. You could create an extension function to make it work though: // Assuming the type of dataManager is DataManager. fun DataManager.createAndSubmitSendIt(title: String, message: String, progressListener: (Long) -> Unit) { createAndSubmitSendIt(title, message, object : ProgressListener { override fun transferred(bytesUploaded: Long) { progressListener(bytesUploaded) } }) } … Read more

Using return inside a lambda?

Just use the qualified return syntax: return@fetchUpcomingTrips. In Kotlin, return inside a lambda means return from the innermost nesting fun (ignoring lambdas), and it is not allowed in lambdas that are not inlined. The return@label syntax is used to specify the scope to return from. You can use the name of the function the lambda … Read more