mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-04 03:06:41 -04:00
Remove nullable and companion object
This commit is contained in:
parent
2d344ff9f1
commit
f8b570dfbb
@ -28,7 +28,7 @@ import org.kiwix.sharedFunctions.MOCK_BASE_URL
|
||||
@Module(includes = [NetworkModule::class])
|
||||
class TestNetworkModule {
|
||||
|
||||
fun provideKiwixService(okHttpClient: OkHttpClient?): KiwixService =
|
||||
fun provideKiwixService(okHttpClient: OkHttpClient): KiwixService =
|
||||
KiwixService.ServiceCreator.newHacklistService(
|
||||
okHttpClient,
|
||||
MOCK_BASE_URL
|
||||
|
@ -32,6 +32,11 @@ import org.kiwix.kiwixmobile.core.data.remote.UserAgentInterceptor
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
import javax.inject.Singleton
|
||||
|
||||
private const val CONNECTION_TIMEOUT = 10L
|
||||
private const val READ_TIMEOUT = 60L
|
||||
private const val USER_AGENT = "kiwix-android-version:${BuildConfig.VERSION_CODE}"
|
||||
private const val KIWIX_DOWNLOAD_URL = "http://mirror.download.kiwix.org/"
|
||||
|
||||
@Module
|
||||
class NetworkModule {
|
||||
@Provides @Singleton fun provideOkHttpClient(): OkHttpClient {
|
||||
@ -41,20 +46,13 @@ class NetworkModule {
|
||||
.addNetworkInterceptor(HttpLoggingInterceptor().apply {
|
||||
level = if (BuildConfig.DEBUG) BASIC else NONE
|
||||
})
|
||||
.addNetworkInterceptor(UserAgentInterceptor(userAgent))
|
||||
.addNetworkInterceptor(UserAgentInterceptor(USER_AGENT))
|
||||
.build()
|
||||
}
|
||||
|
||||
@Provides @Singleton fun provideKiwixService(okHttpClient: OkHttpClient?): KiwixService =
|
||||
@Provides @Singleton fun provideKiwixService(okHttpClient: OkHttpClient): KiwixService =
|
||||
ServiceCreator.newHacklistService(okHttpClient, KIWIX_DOWNLOAD_URL)
|
||||
|
||||
@Provides @Singleton fun provideConnectivityManager(context: Context): ConnectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
||||
companion object {
|
||||
private const val CONNECTION_TIMEOUT = 10L
|
||||
private const val READ_TIMEOUT = 60L
|
||||
private const val userAgent = "kiwix-android-version:${BuildConfig.VERSION_CODE}"
|
||||
private const val KIWIX_DOWNLOAD_URL = "http://mirror.download.kiwix.org/"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user