From 886ca32715ebf550b33641110d527bb9b7ece2df Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 31 Jan 2020 21:25:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/help/http/HttpHelper.kt | 4 ++-- .../http/api/HttpGetApi.kt} | 4 ++-- .../http/api/HttpPostApi.kt} | 4 ++-- .../app/model/analyzeRule/AnalyzeUrl.kt | 20 +++++++++---------- .../app/service/HttpReadAloudService.kt | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) rename app/src/main/java/io/legado/app/{data/api/IHttpGetApi.kt => help/http/api/HttpGetApi.kt} (93%) rename app/src/main/java/io/legado/app/{data/api/IHttpPostApi.kt => help/http/api/HttpPostApi.kt} (95%) 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 3e6d6c3ab..7ba5c4058 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 @@ -1,6 +1,6 @@ package io.legado.app.help.http -import io.legado.app.data.api.IHttpGetApi +import io.legado.app.help.http.api.HttpGetApi import io.legado.app.utils.NetworkUtils import kotlinx.coroutines.suspendCancellableCoroutine import okhttp3.* @@ -39,7 +39,7 @@ object HttpHelper { fun simpleGet(url: String, encode: String? = null): String? { NetworkUtils.getBaseUrl(url)?.let { baseUrl -> - val response = getApiService(baseUrl, encode) + val response = getApiService(baseUrl, encode) .get(url, mapOf()) .execute() return response.body() diff --git a/app/src/main/java/io/legado/app/data/api/IHttpGetApi.kt b/app/src/main/java/io/legado/app/help/http/api/HttpGetApi.kt similarity index 93% rename from app/src/main/java/io/legado/app/data/api/IHttpGetApi.kt rename to app/src/main/java/io/legado/app/help/http/api/HttpGetApi.kt index e4180fa59..46346d091 100644 --- a/app/src/main/java/io/legado/app/data/api/IHttpGetApi.kt +++ b/app/src/main/java/io/legado/app/help/http/api/HttpGetApi.kt @@ -1,4 +1,4 @@ -package io.legado.app.data.api +package io.legado.app.help.http.api import kotlinx.coroutines.Deferred import retrofit2.Call @@ -13,7 +13,7 @@ import retrofit2.http.Url * get web content */ -interface IHttpGetApi { +interface HttpGetApi { @GET fun getAsync( @Url url: String, diff --git a/app/src/main/java/io/legado/app/data/api/IHttpPostApi.kt b/app/src/main/java/io/legado/app/help/http/api/HttpPostApi.kt similarity index 95% rename from app/src/main/java/io/legado/app/data/api/IHttpPostApi.kt rename to app/src/main/java/io/legado/app/help/http/api/HttpPostApi.kt index 17bf16ee8..8dab48762 100644 --- a/app/src/main/java/io/legado/app/data/api/IHttpPostApi.kt +++ b/app/src/main/java/io/legado/app/help/http/api/HttpPostApi.kt @@ -1,4 +1,4 @@ -package io.legado.app.data.api +package io.legado.app.help.http.api import kotlinx.coroutines.Deferred import okhttp3.RequestBody @@ -11,7 +11,7 @@ import retrofit2.http.* * post */ -interface IHttpPostApi { +interface HttpPostApi { @FormUrlEncoded @POST diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index b5343cf7f..4c278e7f9 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -6,14 +6,14 @@ import androidx.annotation.Keep import io.legado.app.constant.AppConst.SCRIPT_ENGINE import io.legado.app.constant.Pattern.EXP_PATTERN import io.legado.app.constant.Pattern.JS_PATTERN -import io.legado.app.data.api.IHttpGetApi -import io.legado.app.data.api.IHttpPostApi import io.legado.app.data.entities.BaseBook import io.legado.app.help.JsExtensions import io.legado.app.help.http.AjaxWebView import io.legado.app.help.http.HttpHelper import io.legado.app.help.http.RequestMethod import io.legado.app.help.http.Res +import io.legado.app.help.http.api.HttpGetApi +import io.legado.app.help.http.api.HttpPostApi import io.legado.app.utils.* import okhttp3.FormBody import okhttp3.MediaType.Companion.toMediaTypeOrNull @@ -248,19 +248,19 @@ class AnalyzeUrl( method == RequestMethod.POST -> { if (fieldMap.isNotEmpty()) { HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .postMap(url, fieldMap, headerMap) } else { HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .postBody(url, body!!, headerMap) } } fieldMap.isEmpty() -> HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .get(url, headerMap) else -> HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .getMap(url, fieldMap, headerMap) } } @@ -284,22 +284,22 @@ class AnalyzeUrl( method == RequestMethod.POST -> { if (fieldMap.isNotEmpty()) { HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .postMapAsync(url, fieldMap, headerMap) .await() } else { HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .postBodyAsync(url, body!!, headerMap) .await() } } fieldMap.isEmpty() -> HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .getAsync(url, headerMap) .await() else -> HttpHelper - .getApiService(baseUrl) + .getApiService(baseUrl) .getMapAsync(url, fieldMap, headerMap) .await() } diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 6f211a3c7..9e1fe70cd 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -3,9 +3,9 @@ package io.legado.app.service import android.app.PendingIntent import android.media.MediaPlayer import io.legado.app.constant.Bus -import io.legado.app.data.api.IHttpPostApi import io.legado.app.help.IntentHelp import io.legado.app.help.http.HttpHelper +import io.legado.app.help.http.api.HttpPostApi import io.legado.app.service.help.ReadBook import io.legado.app.utils.* import kotlinx.coroutines.Dispatchers.IO @@ -65,7 +65,7 @@ class HttpReadAloudService : BaseReadAloudService(), for (index in 0 until contentList.size) { if (isActive) { val bytes = HttpHelper.getByteRetrofit("http://tts.baidu.com") - .create(IHttpPostApi::class.java) + .create(HttpPostApi::class.java) .postMapByteAsync( "http://tts.baidu.com/text2audio", getAudioBody(contentList[index]), mapOf()