mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -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])
|
@Module(includes = [NetworkModule::class])
|
||||||
class TestNetworkModule {
|
class TestNetworkModule {
|
||||||
|
|
||||||
fun provideKiwixService(okHttpClient: OkHttpClient?): KiwixService =
|
fun provideKiwixService(okHttpClient: OkHttpClient): KiwixService =
|
||||||
KiwixService.ServiceCreator.newHacklistService(
|
KiwixService.ServiceCreator.newHacklistService(
|
||||||
okHttpClient,
|
okHttpClient,
|
||||||
MOCK_BASE_URL
|
MOCK_BASE_URL
|
||||||
|
@ -32,6 +32,11 @@ import org.kiwix.kiwixmobile.core.data.remote.UserAgentInterceptor
|
|||||||
import java.util.concurrent.TimeUnit.SECONDS
|
import java.util.concurrent.TimeUnit.SECONDS
|
||||||
import javax.inject.Singleton
|
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
|
@Module
|
||||||
class NetworkModule {
|
class NetworkModule {
|
||||||
@Provides @Singleton fun provideOkHttpClient(): OkHttpClient {
|
@Provides @Singleton fun provideOkHttpClient(): OkHttpClient {
|
||||||
@ -41,20 +46,13 @@ class NetworkModule {
|
|||||||
.addNetworkInterceptor(HttpLoggingInterceptor().apply {
|
.addNetworkInterceptor(HttpLoggingInterceptor().apply {
|
||||||
level = if (BuildConfig.DEBUG) BASIC else NONE
|
level = if (BuildConfig.DEBUG) BASIC else NONE
|
||||||
})
|
})
|
||||||
.addNetworkInterceptor(UserAgentInterceptor(userAgent))
|
.addNetworkInterceptor(UserAgentInterceptor(USER_AGENT))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides @Singleton fun provideKiwixService(okHttpClient: OkHttpClient?): KiwixService =
|
@Provides @Singleton fun provideKiwixService(okHttpClient: OkHttpClient): KiwixService =
|
||||||
ServiceCreator.newHacklistService(okHttpClient, KIWIX_DOWNLOAD_URL)
|
ServiceCreator.newHacklistService(okHttpClient, KIWIX_DOWNLOAD_URL)
|
||||||
|
|
||||||
@Provides @Singleton fun provideConnectivityManager(context: Context): ConnectivityManager =
|
@Provides @Singleton fun provideConnectivityManager(context: Context): ConnectivityManager =
|
||||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as 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