diff --git a/core/network/src/demo/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt b/core/network/src/demo/java/com/google/samples/apps/nowinandroid/core/network/di/FlavoredNetworkModule.kt similarity index 58% rename from core/network/src/demo/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt rename to core/network/src/demo/java/com/google/samples/apps/nowinandroid/core/network/di/FlavoredNetworkModule.kt index c8b3a3208..ee8534c10 100644 --- a/core/network/src/demo/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt +++ b/core/network/src/demo/java/com/google/samples/apps/nowinandroid/core/network/di/FlavoredNetworkModule.kt @@ -16,39 +16,17 @@ package com.google.samples.apps.nowinandroid.core.network.di -import android.content.Context import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource -import com.google.samples.apps.nowinandroid.core.network.fake.FakeAssetManager import com.google.samples.apps.nowinandroid.core.network.fake.FakeNiaNetworkDataSource import dagger.Binds import dagger.Module -import dagger.Provides import dagger.hilt.InstallIn -import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent -import javax.inject.Singleton -import kotlinx.serialization.json.Json @Module @InstallIn(SingletonComponent::class) -interface NetworkModule { +interface FlavoredNetworkModule { @Binds - fun bindsNiaNetwork( - niANetwork: FakeNiaNetworkDataSource - ): NiaNetworkDataSource - - companion object { - @Provides - @Singleton - fun providesNetworkJson(): Json = Json { - ignoreUnknownKeys = true - } - - @Provides - @Singleton - fun providesFakeAssetManager( - @ApplicationContext context: Context, - ): FakeAssetManager = FakeAssetManager(context.assets::open) - } + fun FakeNiaNetworkDataSource.binds(): NiaNetworkDataSource } diff --git a/core/network/src/benchmark/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt b/core/network/src/main/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt similarity index 63% rename from core/network/src/benchmark/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt rename to core/network/src/main/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt index 504d634af..d6b6b987d 100644 --- a/core/network/src/benchmark/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt +++ b/core/network/src/main/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt @@ -17,38 +17,28 @@ package com.google.samples.apps.nowinandroid.core.network.di import android.content.Context -import com.google.samples.apps.nowinandroid.core.network.NiANetwork import com.google.samples.apps.nowinandroid.core.network.fake.FakeAssetManager -import com.google.samples.apps.nowinandroid.core.network.fake.FakeNiANetwork -import dagger.Binds import dagger.Module import dagger.Provides -import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import javax.inject.Singleton import kotlinx.serialization.json.Json @Module @InstallIn(SingletonComponent::class) -interface NetworkModule { - - @Binds - fun bindsNiANetwork( - niANetwork: FakeNiANetwork - ): NiANetwork +object NetworkModule { - companion object { - @Provides - @Singleton - fun providesNetworkJson(): Json = Json { - ignoreUnknownKeys = true - } - - @Provides - @Singleton - fun providesFakeAssetManager( - @ApplicationContext context: Context - ): FakeAssetManager = FakeAssetManager(context.assets::open) + @Provides + @Singleton + fun providesNetworkJson(): Json = Json { + ignoreUnknownKeys = true } + + @Provides + @Singleton + fun providesFakeAssetManager( + @ApplicationContext context: Context, + ): FakeAssetManager = FakeAssetManager(context.assets::open) } diff --git a/core/network/src/prod/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt b/core/network/src/prod/java/com/google/samples/apps/nowinandroid/core/network/di/FlavoredNetworkModule.kt similarity index 58% rename from core/network/src/prod/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt rename to core/network/src/prod/java/com/google/samples/apps/nowinandroid/core/network/di/FlavoredNetworkModule.kt index 15898b4e8..ab463e99c 100644 --- a/core/network/src/prod/java/com/google/samples/apps/nowinandroid/core/network/di/NetworkModule.kt +++ b/core/network/src/prod/java/com/google/samples/apps/nowinandroid/core/network/di/FlavoredNetworkModule.kt @@ -16,39 +16,17 @@ package com.google.samples.apps.nowinandroid.core.network.di -import android.content.Context -import com.google.samples.apps.nowinandroid.core.network.fake.FakeAssetManager import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource import com.google.samples.apps.nowinandroid.core.network.retrofit.RetrofitNiaNetwork import dagger.Binds import dagger.Module -import dagger.Provides -import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import javax.inject.Singleton -import kotlinx.serialization.json.Json @Module @InstallIn(SingletonComponent::class) -interface NetworkModule { +interface FlavoredNetworkModule { @Binds - fun bindsNiaNetwork( - niANetwork: RetrofitNiaNetwork - ): NiaNetworkDataSource - - companion object { - @Provides - @Singleton - fun providesNetworkJson(): Json = Json { - ignoreUnknownKeys = true - } - - @Provides - @Singleton - fun providesFakeAssetManager( - @ApplicationContext context: Context, - ): FakeAssetManager = FakeAssetManager(context.assets::open) - } + fun RetrofitNiaNetwork.binds(): NiaNetworkDataSource }