Last active
January 1, 2019 20:59
-
-
Save piotrmadry/9293adb78e4700431140d0310b6644c1 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 : Activity> Context.open() = startActivity(Intent(this, T::class.java)) | |
inline fun <reified T : Activity> Context.openForResult(code: Int) = startActivityForResult(Intent(this, T::class.java), code) | |
inline fun <reified T : Fragment> newInstance(): T = T::class.java.newInstance() | |
Usage: | |
open<LoginActivity>() | |
openForResult<LoginActivity>(INTENT_CODE) | |
supportFragmentManager | |
.beginTransaction() | |
.replace(R.id.login_fragment_container, newInstance<LoginFragment>()) | |
.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment