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