From 75359cbeb723ea6899ebe5f9a5b2648fe8f3626d Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 18 Feb 2020 16:34:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/http/HttpHelper.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt index b01be8604..f612dea82 100644 --- a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt @@ -9,6 +9,7 @@ import java.util.* import java.util.concurrent.TimeUnit import kotlin.coroutines.resume +@Suppress("unused") object HttpHelper { val client: OkHttpClient by lazy { @@ -47,6 +48,15 @@ object HttpHelper { return null } + suspend fun simpleGetSync(url: String, encode: String? = null): String? { + NetworkUtils.getBaseUrl(url)?.let { baseUrl -> + val response = getApiService(baseUrl, encode) + .getAsync(url, mapOf()) + return response.body() + } + return null + } + inline fun getApiService(baseUrl: String, encode: String? = null): T { return getRetrofit(baseUrl, encode).create(T::class.java) }