mirror of
https://github.com/revanced/revanced-manager-compose-old.git
synced 2025-04-29 22:14:28 +02:00
feat: use ktor for caching
This commit is contained in:
parent
45829d00bb
commit
947fccfb4e
@ -120,7 +120,7 @@ dependencies {
|
||||
implementation("com.mikepenz:aboutlibraries-compose:10.5.1")
|
||||
|
||||
// Ktor
|
||||
val ktorVersion = "2.1.3"
|
||||
val ktorVersion = "2.2.1"
|
||||
implementation("io.ktor:ktor-client-core:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-logging:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
|
||||
|
@ -1,17 +1,14 @@
|
||||
package app.revanced.manager.di
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import app.revanced.manager.util.tag
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.okhttp.*
|
||||
import io.ktor.client.plugins.cache.*
|
||||
import io.ktor.client.plugins.cache.storage.*
|
||||
import io.ktor.client.plugins.contentnegotiation.*
|
||||
import io.ktor.client.plugins.logging.*
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Cache
|
||||
import okhttp3.Dns
|
||||
import okhttp3.Protocol
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.dsl.module
|
||||
@ -32,7 +29,6 @@ val httpModule = module {
|
||||
}
|
||||
}
|
||||
})
|
||||
cache(Cache(context.cacheDir.resolve("cache").also { it.mkdirs() }, 1024 * 1024 * 100))
|
||||
followRedirects(true)
|
||||
followSslRedirects(true)
|
||||
}
|
||||
@ -40,6 +36,10 @@ val httpModule = module {
|
||||
install(ContentNegotiation) {
|
||||
json(json)
|
||||
}
|
||||
install(HttpCache) {
|
||||
val cache = context.cacheDir.resolve("cache")
|
||||
publicStorage(FileStorage(cache))
|
||||
}
|
||||
}
|
||||
|
||||
fun provideJson() = Json {
|
||||
|
Loading…
x
Reference in New Issue
Block a user