Add missing binding in NetworkModule

pull/417/head
Simon Marquis 2 years ago
parent b5d342468e
commit 7e0bfb43fa

@ -16,7 +16,6 @@
package com.google.samples.apps.nowinandroid.core.data.di
import android.content.Context
import com.google.samples.apps.nowinandroid.core.data.repository.AuthorsRepository
import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository
import com.google.samples.apps.nowinandroid.core.data.repository.OfflineFirstAuthorsRepository
@ -27,27 +26,15 @@ import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepositor
import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository
import com.google.samples.apps.nowinandroid.core.data.util.ConnectivityManagerNetworkMonitor
import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor
import com.google.samples.apps.nowinandroid.core.network.fake.FakeAssetManager
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
@Module
@InstallIn(SingletonComponent::class)
interface DataModule {
companion object {
@Provides
@Singleton
fun providesFakeAssetManager(
@ApplicationContext context: Context
): FakeAssetManager = FakeAssetManager(context.assets::open)
}
@Binds
fun bindsTopicRepository(
topicsRepository: OfflineFirstTopicsRepository

@ -16,11 +16,14 @@
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.components.SingletonComponent
import javax.inject.Singleton
@ -41,5 +44,11 @@ interface NetworkModule {
fun providesNetworkJson(): Json = Json {
ignoreUnknownKeys = true
}
@Provides
@Singleton
fun providesFakeAssetManager(
@ApplicationContext context: Context
): FakeAssetManager = FakeAssetManager(context.assets::open)
}
}

@ -16,12 +16,15 @@
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
@ -41,5 +44,11 @@ interface NetworkModule {
fun providesNetworkJson(): Json = Json {
ignoreUnknownKeys = true
}
@Provides
@Singleton
fun providesFakeAssetManager(
@ApplicationContext context: Context,
): FakeAssetManager = FakeAssetManager(context.assets::open)
}
}

@ -16,11 +16,14 @@
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
@ -41,5 +44,11 @@ interface NetworkModule {
fun providesNetworkJson(): Json = Json {
ignoreUnknownKeys = true
}
@Provides
@Singleton
fun providesFakeAssetManager(
@ApplicationContext context: Context,
): FakeAssetManager = FakeAssetManager(context.assets::open)
}
}

Loading…
Cancel
Save