mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Use cronet call factory for api requests.
This commit is contained in:
parent
9193c86e54
commit
1f78d4d2c5
@ -89,5 +89,6 @@ dependencies {
|
|||||||
|
|
||||||
coreLibraryDesugaring libs.desugaring
|
coreLibraryDesugaring libs.desugaring
|
||||||
implementation libs.cronet.embedded
|
implementation libs.cronet.embedded
|
||||||
|
implementation libs.cronet.okhttp
|
||||||
implementation libs.gson
|
implementation libs.gson
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.libretube.util
|
package com.github.libretube.util
|
||||||
|
|
||||||
|
import com.google.net.cronet.okhttptransport.CronetCallFactory
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.jackson.JacksonConverterFactory
|
import retrofit2.converter.jackson.JacksonConverterFactory
|
||||||
|
|
||||||
@ -7,9 +8,13 @@ object RetrofitInstance {
|
|||||||
lateinit var url: String
|
lateinit var url: String
|
||||||
lateinit var authUrl: String
|
lateinit var authUrl: String
|
||||||
val lazyMgr = resettableManager()
|
val lazyMgr = resettableManager()
|
||||||
|
private val callFactory: CronetCallFactory =
|
||||||
|
CronetCallFactory.newBuilder(CronetHelper.getCronetEngine())
|
||||||
|
.build()
|
||||||
val api: PipedApi by resettableLazy(lazyMgr) {
|
val api: PipedApi by resettableLazy(lazyMgr) {
|
||||||
Retrofit.Builder()
|
Retrofit.Builder()
|
||||||
.baseUrl(url)
|
.baseUrl(url)
|
||||||
|
.callFactory(callFactory)
|
||||||
.addConverterFactory(JacksonConverterFactory.create())
|
.addConverterFactory(JacksonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
.create(PipedApi::class.java)
|
.create(PipedApi::class.java)
|
||||||
@ -17,6 +22,7 @@ object RetrofitInstance {
|
|||||||
val authApi: PipedApi by resettableLazy(lazyMgr) {
|
val authApi: PipedApi by resettableLazy(lazyMgr) {
|
||||||
Retrofit.Builder()
|
Retrofit.Builder()
|
||||||
.baseUrl(authUrl)
|
.baseUrl(authUrl)
|
||||||
|
.callFactory(callFactory)
|
||||||
.addConverterFactory(JacksonConverterFactory.create())
|
.addConverterFactory(JacksonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
.create(PipedApi::class.java)
|
.create(PipedApi::class.java)
|
||||||
|
@ -16,6 +16,7 @@ jacksonAnnotations = "2.13.3"
|
|||||||
mobileffmpeg = "4.5.1.LTS"
|
mobileffmpeg = "4.5.1.LTS"
|
||||||
desugaring = "1.1.5"
|
desugaring = "1.1.5"
|
||||||
cronetEmbedded = "101.4951.41"
|
cronetEmbedded = "101.4951.41"
|
||||||
|
cronetOkHttp = "0.1.0"
|
||||||
leakcanary = "2.8.1"
|
leakcanary = "2.8.1"
|
||||||
gson = "2.9.0"
|
gson = "2.9.0"
|
||||||
|
|
||||||
@ -41,5 +42,6 @@ mobileffmpeg = { group = "com.arthenica", name = "ffmpeg-kit-min", version.ref =
|
|||||||
desugaring = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugaring" }
|
desugaring = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugaring" }
|
||||||
exoplayer-extension-cronet = { group = "com.google.android.exoplayer", name = "extension-cronet", version.ref = "exoplayer" }
|
exoplayer-extension-cronet = { group = "com.google.android.exoplayer", name = "extension-cronet", version.ref = "exoplayer" }
|
||||||
cronet-embedded = { group = "org.chromium.net", name = "cronet-embedded", version.ref = "cronetEmbedded" }
|
cronet-embedded = { group = "org.chromium.net", name = "cronet-embedded", version.ref = "cronetEmbedded" }
|
||||||
|
cronet-okhttp = { group = "com.google.net.cronet", name = "cronet-okhttp", version.ref = "cronetOkHttp" }
|
||||||
square-leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" }
|
square-leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" }
|
||||||
gson = { group = "com.google.code.gson", name="gson", version.ref = "gson"}
|
gson = { group = "com.google.code.gson", name="gson", version.ref = "gson"}
|
Loading…
x
Reference in New Issue
Block a user