Last active
August 18, 2019 13:10
-
-
Save jknair0/c7a528b65c7258597510f4a185bbd6fa to your computer and use it in GitHub Desktop.
android context extension functions
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 : AppCompatActivity> Context.startActivity(intentExtras: Intent.() -> Unit = {}) { | |
| startActivity(Intent(this, T::class.java).apply { | |
| this.intentExtras() | |
| }) | |
| } | |
| fun Context.inflate( | |
| @LayoutRes layoutRes: Int, root: ViewGroup? = null, | |
| attachToParent: Boolean = false | |
| ): View { | |
| return LayoutInflater.from(this).inflate(layoutRes, root, attachToParent) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment