lawlorslaw
06/26/2020, 3:30 PM@Module
@InstallIn(ApplicationComponent::class)
class NetworkModule {
@Provides
fun provideCache(@ApplicationContext context: Context): Cache? {
val cacheSize = 10 * 1024 * 1024L // 10MB
var cache: Cache? = null
// Install an HTTP cache in the application cache directory.
try {
val cacheDir = File(context.cacheDir, "http")
cache = Cache(cacheDir, cacheSize)
} catch (e: Exception) {
Timber.e(e, "Unable to install disk cache.")
}
return cache
}
// Other dependencies ...
}