Created
July 21, 2020 16:16
-
-
Save lawloretienne/c358e0b9cdecb24f20cab831697054b5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 SettingsFragment : Fragment() { | |
private val settingsViewModel: SettingsViewModel by viewModels() | |
// ... | |
} | |
class SettingsViewModel @ViewModelInject constructor() : ViewModel() { | |
// ... | |
} | |
@HiltAndroidApp | |
class Application : MultiDexApplication() { | |
// ... | |
} | |
@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 | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment