-
-
Save gtomek/7e4009d4caf13bd87475f59c88269cef to your computer and use it in GitHub Desktop.
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
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