Address some OkHttp nullability changes
This commit is contained in:
@@ -80,7 +80,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
|
||||
authClient.newCall(GET(url.toString()))
|
||||
.await()
|
||||
.use {
|
||||
var responseBody = it.body?.string().orEmpty()
|
||||
var responseBody = it.body.string()
|
||||
if (responseBody.isEmpty()) {
|
||||
throw Exception("Null Response")
|
||||
}
|
||||
@@ -135,8 +135,8 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
|
||||
.build()
|
||||
|
||||
// TODO: get user readed chapter here
|
||||
var response = authClient.newCall(requestUserRead).await()
|
||||
var responseBody = response.body?.string().orEmpty()
|
||||
val response = authClient.newCall(requestUserRead).await()
|
||||
val responseBody = response.body.string()
|
||||
if (responseBody.isEmpty()) {
|
||||
throw Exception("Null Response")
|
||||
}
|
||||
@@ -183,10 +183,6 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
|
||||
private const val redirectUrl = "tachiyomi://bangumi-auth"
|
||||
private const val baseMangaUrl = "$apiUrl/mangas"
|
||||
|
||||
fun mangaUrl(remoteId: Int): String {
|
||||
return "$baseMangaUrl/$remoteId"
|
||||
}
|
||||
|
||||
fun authUrl(): Uri =
|
||||
loginUrl.toUri().buildUpon()
|
||||
.appendQueryParameter("client_id", clientId)
|
||||
|
||||
@@ -24,7 +24,7 @@ class BangumiInterceptor(val bangumi: Bangumi) : Interceptor {
|
||||
if (currAuth.isExpired()) {
|
||||
val response = chain.proceed(BangumiApi.refreshTokenRequest(currAuth.refresh_token!!))
|
||||
if (response.isSuccessful) {
|
||||
newAuth(json.decodeFromString<OAuth>(response.body!!.string()))
|
||||
newAuth(json.decodeFromString<OAuth>(response.body.string()))
|
||||
} else {
|
||||
response.close()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class KitsuInterceptor(val kitsu: Kitsu) : Interceptor {
|
||||
if (currAuth.isExpired()) {
|
||||
val response = chain.proceed(KitsuApi.refreshTokenRequest(refreshToken))
|
||||
if (response.isSuccessful) {
|
||||
newAuth(json.decodeFromString(response.body!!.string()))
|
||||
newAuth(json.decodeFromString(response.body.string()))
|
||||
} else {
|
||||
response.close()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class ShikimoriInterceptor(val shikimori: Shikimori) : Interceptor {
|
||||
if (currAuth.isExpired()) {
|
||||
val response = chain.proceed(ShikimoriApi.refreshTokenRequest(refreshToken))
|
||||
if (response.isSuccessful) {
|
||||
newAuth(json.decodeFromString<OAuth>(response.body!!.string()))
|
||||
newAuth(json.decodeFromString<OAuth>(response.body.string()))
|
||||
} else {
|
||||
response.close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user