Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created July 2, 2020 07:34
Show Gist options
  • Save manuelvicnt/55132814c402ea5a9276dafed3e5ea86 to your computer and use it in GitHub Desktop.
Save manuelvicnt/55132814c402ea5a9276dafed3e5ea86 to your computer and use it in GitHub Desktop.
Adding components to the Hilt hierarchy - 4
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
// Injected by ActivityComponent
@Inject lateinit var userManager: UserManager
// Populated by UserComponent
private lateinit var userDataRepository: UserDataRepository
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
userDataRepository = EntryPoints.get(
userManager.userComponent, UserComponentEntryPoint::class.java
).userDataRepository()
// Do something with userDataRepository
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment