Skip to content

Instantly share code, notes, and snippets.

@sembozdemir
Last active November 26, 2017 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sembozdemir/4eb598e16a9aba693a62c6b6984c48e8 to your computer and use it in GitHub Desktop.
Save sembozdemir/4eb598e16a9aba693a62c6b6984c48e8 to your computer and use it in GitHub Desktop.
Picassos.kt
import android.widget.ImageView
fun com.squareup.picasso.RequestCreator.into(target: ImageView, func: __Callback.() -> Unit) {
val callback = __Callback()
callback.func()
into(target, callback)
}
class __Callback : com.squareup.picasso.Callback {
private var _onSuccess: (() -> Unit)? = null
private var _onError: (() -> Unit)? = null
override fun onSuccess() {
_onSuccess?.invoke()
}
fun onSuccess(func: () -> Unit) {
_onSuccess = func
}
override fun onError() {
_onError?.invoke()
}
fun onError(func: () -> Unit) {
_onError = func
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment