正文图片下载:删除多余代码

pull/439/head
AndyBernie 4 years ago
parent 6e99db4add
commit e27211ff80
  1. 2
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 15
      app/src/main/java/io/legado/app/help/http/HttpHelper.kt
  3. 12
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -101,7 +101,7 @@ object BookHelp {
downloadImages.add(src)
val analyzeUrl = AnalyzeUrl(src)
try {
analyzeUrl.getImageBytes(book.origin)?.let {
analyzeUrl.getResponseBytes(book.origin)?.let {
FileUtils.createFileIfNotExist(
downloadDir,
cacheFolderName,

@ -48,21 +48,6 @@ object HttpHelper {
return null
}
fun getBytes(
url: String,
queryMap: Map<String, String>,
headers: Map<String, String>
): ByteArray? {
NetworkUtils.getBaseUrl(url)?.let { baseUrl ->
return getByteRetrofit(baseUrl)
.create(HttpGetApi::class.java)
.getMapByte(url, queryMap, headers)
.execute()
.body()
}
return null
}
suspend fun simpleGetAsync(url: String, encode: String? = null): String? {
NetworkUtils.getBaseUrl(url)?.let { baseUrl ->
val response = getApiService<HttpGetApi>(baseUrl, encode)

@ -352,18 +352,6 @@ class AnalyzeUrl(
return Res(NetworkUtils.getUrl(res), res.body())
}
fun getImageBytes(tag: String): ByteArray? {
val cookie = CookieStore.getCookie(tag)
if (cookie.isNotEmpty()) {
headerMap["Cookie"] += cookie
}
return if (fieldMap.isEmpty()) {
HttpHelper.getBytes(url, mapOf(), headerMap)
} else {
HttpHelper.getBytes(url, fieldMap, headerMap)
}
}
suspend fun getResponseBytes(tag: String? = null): ByteArray? {
if (tag != null) {
val cookie = CookieStore.getCookie(tag)

Loading…
Cancel
Save