Last active
December 3, 2017 02:42
-
-
Save pokk/d68f06f62b2b4ef0c90733c2513fb1ea 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
class App: Application() { | |
companion object { | |
lateinit private var context: Context | |
@JvmStatic fun appComponent(): AppComponent = (context as App).appComponent | |
// Provide the global application context. | |
@JvmStatic fun getAppContext(): Context = context | |
} | |
// Before dagger 2.11 | |
private val appComponent: AppComponent by lazy { AppComponent.Initializer.init(App@ this) } | |
override fun onCreate() { | |
super.onCreate() | |
context = this | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment