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
Components -- - Created at - - - Destroyed at | |
SingletonComponents - - Application#Oncreate() - - - Application#Destroyed() | |
ActivityRetainedComponents - Activity#Oncreate() - Activity#OnDestroy() | |
ViewModelComponents - - ViewModel create - - ViewModel destroy | |
ActivityComponents- - Activity#Oncreate() - -Activity#OnDestroy() | |
FragmentComponents - - Fragment#OnAttached() - - Fragment#OnDettached() | |
ViewComponents - - View#super() - - - - - View destroy | |
ViewWithFragmentComponent - - View#super() - -- View destroy | |
ServiceComponent - - Service#OnCreate()- - Service#OnDestroy() |
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
// As a dependency of a constructor-injected class. | |
class ExampleServiceImpl @Inject constructor( | |
@AuthInterceptorOkHttpClient private val okHttpClient: OkHttpClient | |
) : ... | |
// At field injection. | |
@AndroidEntryPoint | |
class ExampleActivity: AppCompatActivity() { | |
@AuthInterceptorOkHttpClient |
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(ActivityComponent::class) | |
object AnalyticsModule { | |
@Provides | |
fun provideAnalyticsService( | |
@AuthInterceptorOkHttpClient okHttpClient: OkHttpClient | |
): AnalyticsService { | |
return Retrofit.Builder() | |
.baseUrl("https://example.com") |
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 NetworkModule { | |
@AuthInterceptorOkHttpClient | |
@Provides | |
fun provideAuthInterceptorOkHttpClient( | |
authInterceptor: AuthInterceptor | |
): OkHttpClient { | |
return OkHttpClient.Builder() |
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
@Qualifier | |
@Retention(AnnotationRetention.BINARY) | |
annotation class AuthInterceptorOkHttpClient | |
@Qualifier | |
@Retention(AnnotationRetention.BINARY) | |
annotation class OtherInterceptorOkHttpClient | |
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
interface AppNavigation{ | |
fun navigateTo(screens: Screens) | |
} | |
class AppNavigationImpl @Inject constructor( | |
... | |
) : AppNavigation{ ... } | |
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(ActivityComponent::class) | |
object AnalyticsModule { | |
@Provides | |
fun provideAnalyticsService( | |
// Potential dependencies of this type | |
): AnalyticsService { | |
return Retrofit.Builder() | |
.baseUrl("https://example.com") |
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
@AndroidEntryPoint | |
class ExampleActivity : AppCompatActivity() { ... } |
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
android { | |
... | |
compileOptions { | |
sourceCompatibility = JavaVersion.VERSION_1_8 | |
targetCompatibility = JavaVersion.VERSION_1_8 | |
} | |
} |
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
plugins { | |
kotlin("kapt") | |
id("dagger.hilt.android.plugin") | |
} | |
android { | |
... | |
} | |
dependencies { |