Created
February 25, 2019 10:38
-
-
Save shkschneider/b3c5d330c748aafca87160c1d67f2441 to your computer and use it in GitHub Desktop.
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
inline fun <reified T: Any> Activity.extra(key: String, default: T? = null) = lazy { | |
val value = intent?.extras?.get(key) | |
if (value is T) value else default | |
} | |
inline fun <reified T: Any> Activity.extraNotNull(key: String, default: T? = null) = lazy { | |
val value = intent?.extras?.get(key) | |
requireNotNull(if (value is T) value else default) { key } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment