diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 751f4906d..79223d416 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/12/14** * 修复bug * 电池图标不允许改字体 +* 升级js库 **2020/12/13** * 修复bug diff --git a/app/src/main/java/io/legado/app/help/http/StrResponse.kt b/app/src/main/java/io/legado/app/help/http/StrResponse.kt index c7ccad9a1..1b1f53395 100644 --- a/app/src/main/java/io/legado/app/help/http/StrResponse.kt +++ b/app/src/main/java/io/legado/app/help/http/StrResponse.kt @@ -8,17 +8,20 @@ import okhttp3.Response.Builder */ @Suppress("unused", "MemberVisibilityCanBePrivate") class StrResponse { - var rawResponse: Response + var raw: Response + private set var body: String? = null + private set var errorBody: ResponseBody? = null + private set constructor(rawResponse: Response, body: String?) { - this.rawResponse = rawResponse + this.raw = rawResponse this.body = body } constructor(url: String, body: String?) { - rawResponse = Builder() + raw = Builder() .code(200) .message("OK") .protocol(Protocol.HTTP_1_1) @@ -28,39 +31,43 @@ class StrResponse { } constructor(rawResponse: Response, errorBody: ResponseBody?) { - this.rawResponse = rawResponse + this.raw = rawResponse this.errorBody = errorBody } - fun raw() = rawResponse + fun raw() = raw fun url(): String { - rawResponse.networkResponse?.let { + raw.networkResponse?.let { return it.request.url.toString() } - return rawResponse.request.url.toString() + return raw.request.url.toString() } + val url: String get() = url() + + fun body() = body + fun code(): Int { - return rawResponse.code + return raw.code } fun message(): String { - return rawResponse.message + return raw.message } fun headers(): Headers { - return rawResponse.headers + return raw.headers } - fun isSuccessful(): Boolean = rawResponse.isSuccessful + fun isSuccessful(): Boolean = raw.isSuccessful fun errorBody(): ResponseBody? { return errorBody } override fun toString(): String { - return rawResponse.toString() + return raw.toString() } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt index 7b2235aab..7a1c29a05 100644 --- a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt @@ -52,7 +52,7 @@ class WebBook(val bookSource: BookSource) { res.body, bookSource, analyzeUrl, - res.url(), + res.url, variableBook, true ) @@ -83,7 +83,7 @@ class WebBook(val bookSource: BookSource) { res.body, bookSource, analyzeUrl, - res.url(), + res.url, variableBook, false )