Clean up OkHttp methods and parse from Okio directly (#8238)

This commit is contained in:
stevenyomi
2022-10-19 00:09:23 +08:00
committed by GitHub
parent f5bde3726a
commit 2d19729869
4 changed files with 21 additions and 16 deletions

View File

@ -1,17 +1,12 @@
package eu.kanade.tachiyomi.data.track.myanimelist
import eu.kanade.tachiyomi.network.parseAs
import kotlinx.serialization.json.Json
import okhttp3.Interceptor
import okhttp3.Response
import okhttp3.internal.closeQuietly
import uy.kohesive.injekt.injectLazy
import java.io.IOException
class MyAnimeListInterceptor(private val myanimelist: MyAnimeList, private var token: String?) : Interceptor {
private val json: Json by injectLazy()
private var oauth: OAuth? = null
override fun intercept(chain: Interceptor.Chain): Response {
@ -31,7 +26,7 @@ class MyAnimeListInterceptor(private val myanimelist: MyAnimeList, private var t
if (oauthResponse.isSuccessful) {
oauthResponse.parseAs<OAuth>()
} else {
oauthResponse.closeQuietly()
oauthResponse.close()
null
}
}