Last active
August 24, 2022 11:32
-
-
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.
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
@Module | |
@InstallIn(SingletonComponent::class) | |
object PowerplayDaggerModule { | |
@EntryPoint | |
@InstallIn(SingletonComponent::class) | |
interface SampleAdapterEntryPointEntryPoint { | |
val sampleClass : SampleClass | |
} | |
} |
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
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