Commit 5a49bd3a authored by vvb2060's avatar vvb2060 Committed by John Wu

Add OkHttp cache

parent b37d7e05
...@@ -9,15 +9,18 @@ import com.topjohnwu.magisk.ktx.precomputedText ...@@ -9,15 +9,18 @@ import com.topjohnwu.magisk.ktx.precomputedText
import com.topjohnwu.magisk.utils.MarkwonImagePlugin import com.topjohnwu.magisk.utils.MarkwonImagePlugin
import io.noties.markwon.Markwon import io.noties.markwon.Markwon
import io.noties.markwon.html.HtmlPlugin import io.noties.markwon.html.HtmlPlugin
import okhttp3.Cache
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory import retrofit2.converter.scalars.ScalarsConverterFactory
import java.io.File
@Suppress("DEPRECATION")
fun createOkHttpClient(context: Context): OkHttpClient { fun createOkHttpClient(context: Context): OkHttpClient {
val builder = OkHttpClient.Builder() val appCache = Cache(File(context.cacheDir, "okhttp"), 10 * 1024 * 1024)
val builder = OkHttpClient.Builder().cache(appCache)
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
builder.addInterceptor(HttpLoggingInterceptor().apply { builder.addInterceptor(HttpLoggingInterceptor().apply {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment