Skip to content

Instantly share code, notes, and snippets.

@bhavesh3005sharma
Last active August 24, 2022 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhavesh3005sharma/d47ec1425d338ff13003c40977c1d595 to your computer and use it in GitHub Desktop.
Save bhavesh3005sharma/d47ec1425d338ff13003c40977c1d595 to your computer and use it in GitHub Desktop.
Script demonstrate how we can inject the dependencies into the classes not supported by Hilt directly.
@Module
@InstallIn(SingletonComponent::class)
object PowerplayDaggerModule {
@EntryPoint
@InstallIn(SingletonComponent::class)
interface SampleAdapterEntryPointEntryPoint {
val sampleClass : SampleClass
}
}
class SampleAdapter : RecyclerView.Adapter<SampleAdapter.ViewHolder>() {
private val sampleClass : SampleClass
init {
val sampleAdapterFactory = EntryPointAccessors.fromApplication(
applicationContext,
PowerplayDaggerModule.SampleAdapterEntryPointEntryPoint::class.java)
sampleClass = sampleAdapterFactory.sampleClass
}
....
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment