mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Added OkHttpDownloader in Fetch.
This commit is contained in:
parent
89d7b87925
commit
2ddc395267
@ -228,7 +228,7 @@ class AllProjectConfigurer {
|
||||
kapt(Libs.roomCompiler)
|
||||
implementation(Libs.tracing)
|
||||
implementation(Libs.fetch)
|
||||
// implementation(Libs.fetchOkhttp)
|
||||
implementation(Libs.fetchOkhttp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,17 +21,23 @@ import android.content.Context
|
||||
import com.tonyodev.fetch2.Fetch
|
||||
import com.tonyodev.fetch2.FetchConfiguration
|
||||
import com.tonyodev.fetch2.FetchNotificationManager
|
||||
import com.tonyodev.fetch2okhttp.OkHttpDownloader
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import okhttp3.OkHttpClient
|
||||
import org.kiwix.kiwixmobile.core.BuildConfig
|
||||
import org.kiwix.kiwixmobile.core.dao.DownloadRoomDao
|
||||
import org.kiwix.kiwixmobile.core.data.remote.BasicAuthInterceptor
|
||||
import org.kiwix.kiwixmobile.core.data.remote.KiwixService
|
||||
import org.kiwix.kiwixmobile.core.downloader.DownloadRequester
|
||||
import org.kiwix.kiwixmobile.core.downloader.Downloader
|
||||
import org.kiwix.kiwixmobile.core.downloader.DownloaderImpl
|
||||
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadManagerRequester
|
||||
import org.kiwix.kiwixmobile.core.downloader.downloadManager.FetchDownloadNotificationManager
|
||||
import org.kiwix.kiwixmobile.core.utils.CONNECT_TIME_OUT
|
||||
import org.kiwix.kiwixmobile.core.utils.READ_TIME_OUT
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@ -61,29 +67,29 @@ object DownloaderModule {
|
||||
@Singleton
|
||||
fun provideFetchConfiguration(
|
||||
context: Context,
|
||||
// okHttpDownloader: OkHttpDownloader,
|
||||
okHttpDownloader: OkHttpDownloader,
|
||||
fetchNotificationManager: FetchNotificationManager
|
||||
): FetchConfiguration =
|
||||
FetchConfiguration.Builder(context).apply {
|
||||
setDownloadConcurrentLimit(5)
|
||||
enableLogging(BuildConfig.DEBUG)
|
||||
enableRetryOnNetworkGain(true)
|
||||
// setHttpDownloader(okHttpDownloader)
|
||||
setHttpDownloader(okHttpDownloader)
|
||||
preAllocateFileOnCreation(false)
|
||||
setNotificationManager(fetchNotificationManager)
|
||||
}.build().also(Fetch.Impl::setDefaultInstanceConfiguration)
|
||||
|
||||
// @Provides
|
||||
// @Singleton
|
||||
// fun provideOkHttpDownloader() = OkHttpDownloader(
|
||||
// OkHttpClient.Builder()
|
||||
// .connectTimeout(CONNECT_TIME_OUT, TimeUnit.MINUTES)
|
||||
// .readTimeout(READ_TIME_OUT, TimeUnit.MINUTES)
|
||||
// .addInterceptor(BasicAuthInterceptor())
|
||||
// .followRedirects(true)
|
||||
// .followSslRedirects(true)
|
||||
// .build()
|
||||
// )
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideOkHttpDownloader() = OkHttpDownloader(
|
||||
OkHttpClient.Builder()
|
||||
.connectTimeout(CONNECT_TIME_OUT, TimeUnit.MINUTES)
|
||||
.readTimeout(READ_TIME_OUT, TimeUnit.MINUTES)
|
||||
.addInterceptor(BasicAuthInterceptor())
|
||||
.followRedirects(true)
|
||||
.followSslRedirects(true)
|
||||
.build()
|
||||
)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
|
Loading…
x
Reference in New Issue
Block a user