feat: 优化代码

pull/123/head
kunfei 5 years ago
parent 8de2bd73d0
commit cb0e81748c
  1. 2
      app/src/main/assets/updateLog.md
  2. 18
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  3. 8
      app/src/main/java/io/legado/app/ui/login/SourceLogin.kt

@ -2,7 +2,7 @@
* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
* 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
**2020/01/01**
**2020/03/01**
* 修复书源解析的一个bug
* 添加底部操作栏颜色配置
* 修复滚动点击翻页,修复滚动最后一页显示加载中

@ -8,10 +8,7 @@ import io.legado.app.constant.Pattern.EXP_PATTERN
import io.legado.app.constant.Pattern.JS_PATTERN
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.*
import io.legado.app.help.http.api.HttpGetApi
import io.legado.app.help.http.api.HttpPostApi
import io.legado.app.utils.*
@ -243,7 +240,11 @@ class AnalyzeUrl(
}
@Throws(Exception::class)
fun getResponse(): Call<String> {
fun getResponse(tag: String): Call<String> {
val cookie = CookieStore.getCookie(tag)
if (cookie.isNotEmpty()) {
headerMap["Cookie"] = cookie
}
return when {
method == RequestMethod.POST -> {
if (fieldMap.isNotEmpty()) {
@ -267,7 +268,7 @@ class AnalyzeUrl(
@Throws(Exception::class)
suspend fun getResponseAwait(
tag: String? = null,
tag: String,
jsStr: String? = null,
sourceRegex: String? = null
): Res {
@ -278,8 +279,13 @@ class AnalyzeUrl(
params.javaScript = jsStr
params.sourceRegex = sourceRegex
params.postData = bodyTxt?.toByteArray()
params.tag = tag
return HttpHelper.ajax(params)
}
val cookie = CookieStore.getCookie(tag)
if (cookie.isNotEmpty()) {
headerMap["Cookie"] = cookie
}
val res = when {
method == RequestMethod.POST -> {
if (fieldMap.isNotEmpty()) {

@ -14,6 +14,8 @@ import io.legado.app.base.BaseActivity
import io.legado.app.data.entities.Cookie
import io.legado.app.utils.snackbar
import kotlinx.android.synthetic.main.activity_source_login.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch
class SourceLogin : BaseActivity(R.layout.activity_source_login) {
@ -74,8 +76,10 @@ class SourceLogin : BaseActivity(R.layout.activity_source_login) {
}
private fun saveCookie(cookie: String) {
sourceUrl?.let {
App.db.cookieDao().insert(Cookie(it, cookie))
launch(IO) {
sourceUrl?.let {
App.db.cookieDao().insert(Cookie(it, cookie))
}
}
}
}
Loading…
Cancel
Save