优化
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions

This commit is contained in:
Horis
2025-03-01 14:11:48 +08:00
parent 544c21e12b
commit 72dbab3d84
3 changed files with 5 additions and 8 deletions

View File

@@ -290,12 +290,12 @@ class EpubFile(var book: Book) {
book.name = book.originName.replace(".epub", "")
}
if (metadata.authors.size > 0) {
if (metadata.authors.isNotEmpty()) {
val author =
metadata.authors[0].toString().replace("^, |, $".toRegex(), "")
book.author = author
}
if (metadata.descriptions.size > 0) {
if (metadata.descriptions.isNotEmpty()) {
val desc = metadata.descriptions[0]
book.intro = if (desc.isXml()) {
Jsoup.parse(metadata.descriptions[0]).text()
@@ -323,7 +323,7 @@ class EpubFile(var book: Book) {
val doc =
Jsoup.parse(String(resource.data, mCharset))
val elements = doc.getElementsByTag("title")
if (elements.size > 0) {
if (elements.isNotEmpty()) {
title = elements[0].text()
}
} catch (e: IOException) {
@@ -385,7 +385,7 @@ class EpubFile(var book: Book) {
String(epubBook!!.resources.getByHref(content.href).data, mCharset)
).getElementsByTag("title")
title =
if (elements.size > 0 && elements[0].text().isNotBlank())
if (elements.isNotEmpty() && elements[0].text().isNotBlank())
elements[0].text()
else
"--卷首--"

View File

@@ -15,7 +15,6 @@ import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.book.update
import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.permission.Permissions
@@ -308,7 +307,7 @@ class ImportBookActivity : BaseImportBookActivity<ImportBookViewModel>(),
val filePath = fileDoc.toString()
if (it.bookUrl != filePath) {
it.bookUrl = filePath
it.update()
appDb.bookDao.insert(it)
}
startReadBook(it)
}

View File

@@ -168,14 +168,12 @@ class ReadBookActivity : BaseReadBookActivity(),
}
private val replaceActivity =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
it ?: return@registerForActivityResult
if (it.resultCode == RESULT_OK) {
viewModel.replaceRuleChanged()
}
}
private val searchContentActivity =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
it ?: return@registerForActivityResult
it.data?.let { data ->
val key = data.getLongExtra("key", System.currentTimeMillis())
val index = data.getIntExtra("index", 0)