Last active
November 26, 2017 12:58
-
-
Save sembozdemir/4eb598e16a9aba693a62c6b6984c48e8 to your computer and use it in GitHub Desktop.
Picassos.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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