Last active
February 16, 2018 12:15
-
-
Save babedev/60f0d78732bae7a3ec5e6ce859e8ca70 to your computer and use it in GitHub Desktop.
Show image with Glide and start intent with Anko
This file contains 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
fun ImageView.show(imageUrl: String = "") { | |
if (imageUrl.isBlank()) return | |
if (context == null) return | |
if (context is Activity && ((context as Activity).isFinishing || (context as Activity).isDestroyed)) return | |
Glide.with(context) | |
.load(imageUrl) | |
.crossFade() | |
.signature(StringSignature(UUID.randomUUID().toString())) | |
.into(this) | |
} | |
fun ImageView.show(imageUri: Uri) { | |
if (context == null) return | |
if (context is Activity && ((context as Activity).isFinishing || (context as Activity).isDestroyed)) return | |
Glide.with(context) | |
.load(imageUri) | |
.crossFade() | |
.signature(StringSignature(UUID.randomUUID().toString())) | |
.into(this) | |
} | |
fun View.callOnClick(phoneNumber: String) { | |
setOnClickListener { context.call(phoneNumber) } | |
} | |
fun View.browseOnClick(webUrl: String) { | |
setOnClickListener { context.browse(webUrl) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample_imageview.show("http://someimageurl.com/123")