From eff260f7e1cc0c2981f766cdc25f06d04d8be9f6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 28 Aug 2021 11:50:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B0=83=E8=AF=95=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/analyzeRule/AnalyzeRule.kt | 3 +- .../source/debug/BookSourceDebugActivity.kt | 49 ++++-- .../book/source/debug/BookSourceDebugModel.kt | 6 +- .../main/res/layout/activity_source_debug.xml | 165 ++++++++++++++++++ 4 files changed, 209 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 2336757fc..780160a25 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -69,8 +69,7 @@ class AnalyzeRule(val ruleData: RuleDataInterface, private val source: BaseSourc fun setRedirectUrl(url: String): URL? { kotlin.runCatching { - val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) - redirectUrl = URL(if (urlMatcher.find()) url.substring(0, urlMatcher.start()) else url) + redirectUrl = URL(url) } return redirectUrl } diff --git a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt index 43c2ba1ae..a7b775f5a 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt @@ -1,14 +1,15 @@ package io.legado.app.ui.book.source.debug +import android.annotation.SuppressLint import android.os.Bundle import android.view.Menu import android.view.MenuItem +import android.view.View import androidx.activity.viewModels import androidx.appcompat.widget.SearchView import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.databinding.ActivitySourceDebugBinding -import io.legado.app.help.LocalConfig import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.qrcode.QrCodeResult @@ -16,6 +17,7 @@ import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.toastOnUi import io.legado.app.utils.viewbindingdelegate.viewBinding import kotlinx.coroutines.launch +import splitties.views.onClick class BookSourceDebugActivity : VMBaseActivity() { @@ -32,9 +34,11 @@ class BookSourceDebugActivity : VMBaseActivity launch { adapter.addItem(msg) @@ -45,13 +49,6 @@ class BookSourceDebugActivity : VMBaseActivity + openOrCloseHelp(hasFocus) + } + } + + @SuppressLint("SetTextI18n") + private fun initHelpView() { + viewModel.bookSource?.exploreKinds?.firstOrNull { + !it.url.isNullOrBlank() + }?.let { + binding.textFx.text = "${it.title}::${it.url}" + } + binding.textMy.onClick { + searchView.setQuery(binding.textMy.text, true) + } + binding.textXt.onClick { + searchView.setQuery(binding.textXt.text, true) + } + binding.textFx.onClick { + searchView.setQuery(binding.textFx.text, true) + } + } + + /** + * 打开关闭历史界面 + */ + private fun openOrCloseHelp(open: Boolean) { + if (open) { + binding.help.visibility = View.VISIBLE + } else { + binding.help.visibility = View.GONE + } } private fun startSearch(key: String) { diff --git a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt index fb94fecce..b7efa3029 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt @@ -9,18 +9,20 @@ import io.legado.app.model.Debug class BookSourceDebugModel(application: Application) : BaseViewModel(application), Debug.Callback { - private var bookSource: BookSource? = null + var bookSource: BookSource? = null private var callback: ((Int, String) -> Unit)? = null var searchSrc: String? = null var bookSrc: String? = null var tocSrc: String? = null var contentSrc: String? = null - fun init(sourceUrl: String?) { + fun init(sourceUrl: String?, finally: () -> Unit) { sourceUrl?.let { //优先使用这个,不会抛出异常 execute { bookSource = appDb.bookSourceDao.getBookSource(sourceUrl) + }.onFinally { + finally.invoke() } } } diff --git a/app/src/main/res/layout/activity_source_debug.xml b/app/src/main/res/layout/activity_source_debug.xml index 94620a861..3dfb93d53 100644 --- a/app/src/main/res/layout/activity_source_debug.xml +++ b/app/src/main/res/layout/activity_source_debug.xml @@ -1,6 +1,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file