feat: 优化代码

pull/95/head
kunfei 5 years ago
parent b68063616f
commit 27bf4f3234
  1. 16
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -248,19 +248,19 @@ class AnalyzeUrl(
method == RequestMethod.POST -> { method == RequestMethod.POST -> {
if (fieldMap.isNotEmpty()) { if (fieldMap.isNotEmpty()) {
HttpHelper HttpHelper
.getApiService<HttpPostApi>(baseUrl) .getApiService<HttpPostApi>(baseUrl, charset)
.postMap(url, fieldMap, headerMap) .postMap(url, fieldMap, headerMap)
} else { } else {
HttpHelper HttpHelper
.getApiService<HttpPostApi>(baseUrl) .getApiService<HttpPostApi>(baseUrl, charset)
.postBody(url, body!!, headerMap) .postBody(url, body!!, headerMap)
} }
} }
fieldMap.isEmpty() -> HttpHelper fieldMap.isEmpty() -> HttpHelper
.getApiService<HttpGetApi>(baseUrl) .getApiService<HttpGetApi>(baseUrl, charset)
.get(url, headerMap) .get(url, headerMap)
else -> HttpHelper else -> HttpHelper
.getApiService<HttpGetApi>(baseUrl) .getApiService<HttpGetApi>(baseUrl, charset)
.getMap(url, fieldMap, headerMap) .getMap(url, fieldMap, headerMap)
} }
} }
@ -284,22 +284,22 @@ class AnalyzeUrl(
method == RequestMethod.POST -> { method == RequestMethod.POST -> {
if (fieldMap.isNotEmpty()) { if (fieldMap.isNotEmpty()) {
HttpHelper HttpHelper
.getApiService<HttpPostApi>(baseUrl) .getApiService<HttpPostApi>(baseUrl, charset)
.postMapAsync(url, fieldMap, headerMap) .postMapAsync(url, fieldMap, headerMap)
.await() .await()
} else { } else {
HttpHelper HttpHelper
.getApiService<HttpPostApi>(baseUrl) .getApiService<HttpPostApi>(baseUrl, charset)
.postBodyAsync(url, body!!, headerMap) .postBodyAsync(url, body!!, headerMap)
.await() .await()
} }
} }
fieldMap.isEmpty() -> HttpHelper fieldMap.isEmpty() -> HttpHelper
.getApiService<HttpGetApi>(baseUrl) .getApiService<HttpGetApi>(baseUrl, charset)
.getAsync(url, headerMap) .getAsync(url, headerMap)
.await() .await()
else -> HttpHelper else -> HttpHelper
.getApiService<HttpGetApi>(baseUrl) .getApiService<HttpGetApi>(baseUrl, charset)
.getMapAsync(url, fieldMap, headerMap) .getMapAsync(url, fieldMap, headerMap)
.await() .await()
} }

Loading…
Cancel
Save