mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -6,6 +6,7 @@ import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.constant.BookType
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.help.AppConfig
|
||||
import io.legado.app.help.ReadBookConfig
|
||||
import io.legado.app.model.ReadBook
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.MD5Utils
|
||||
@@ -149,7 +150,7 @@ data class Book(
|
||||
}
|
||||
|
||||
fun getUseReplaceRule(): Boolean {
|
||||
return config().useReplaceRule
|
||||
return config().useReplaceRule ?: AppConfig.replaceEnableDefault
|
||||
}
|
||||
|
||||
fun getReSegment(): Boolean {
|
||||
@@ -169,10 +170,14 @@ data class Book(
|
||||
}
|
||||
|
||||
fun getPageAnim(): Int {
|
||||
return config().pageAnim
|
||||
var pageAnim = config().pageAnim ?: ReadBookConfig.pageAnim
|
||||
if (pageAnim < 0) {
|
||||
pageAnim = ReadBookConfig.pageAnim
|
||||
}
|
||||
return pageAnim
|
||||
}
|
||||
|
||||
fun setPageAnim(pageAnim: Int) {
|
||||
fun setPageAnim(pageAnim: Int?) {
|
||||
config().pageAnim = pageAnim
|
||||
}
|
||||
|
||||
@@ -276,11 +281,11 @@ data class Book(
|
||||
@Parcelize
|
||||
data class ReadConfig(
|
||||
var reverseToc: Boolean = false,
|
||||
var pageAnim: Int = -1,
|
||||
var pageAnim: Int? = null,
|
||||
var reSegment: Boolean = false,
|
||||
var limitContentLength: Boolean = true, //txt规则解析目录时超过规定的最大字数时均分txt
|
||||
var imageStyle: String? = null,
|
||||
var useReplaceRule: Boolean = AppConfig.replaceEnableDefault,// 正文使用净化替换规则
|
||||
var useReplaceRule: Boolean? = null,// 正文使用净化替换规则
|
||||
var delTag: Long = 0L,//去除标签
|
||||
) : Parcelable
|
||||
|
||||
|
||||
@@ -402,13 +402,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
}
|
||||
|
||||
fun pageAnim(): Int {
|
||||
book?.let {
|
||||
return if (it.getPageAnim() < 0)
|
||||
ReadBookConfig.pageAnim
|
||||
else
|
||||
it.getPageAnim()
|
||||
}
|
||||
return ReadBookConfig.pageAnim
|
||||
return book?.getPageAnim() ?: ReadBookConfig.pageAnim
|
||||
}
|
||||
|
||||
fun setCharset(charset: String) {
|
||||
|
||||
@@ -126,7 +126,7 @@ class ReadStyleDialog : BaseDialogFragment(R.layout.dialog_read_book_style),
|
||||
TipConfigDialog().show(childFragmentManager, "tipConfigDialog")
|
||||
}
|
||||
rgPageAnim.setOnCheckedChangeListener { _, checkedId ->
|
||||
ReadBook.book?.setPageAnim(-1)
|
||||
ReadBook.book?.setPageAnim(null)
|
||||
ReadBookConfig.pageAnim = binding.rgPageAnim.getIndexById(checkedId)
|
||||
callBack?.upPageAnim()
|
||||
ReadBook.loadContent(false)
|
||||
|
||||
@@ -110,6 +110,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
|
||||
else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey)
|
||||
}.collect {
|
||||
if (!(searchKey.isNullOrBlank() && it.isEmpty())) {
|
||||
binding.rotateLoading.show()
|
||||
val data = withContext(IO) {
|
||||
val replaces = viewModel.bookData.value?.let { book ->
|
||||
ContentProcessor.get(book.name, book.origin).getReplaceRules()
|
||||
@@ -118,11 +119,12 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
|
||||
it.map { chapter ->
|
||||
Pair(
|
||||
chapter,
|
||||
async(start = CoroutineStart.LAZY) {
|
||||
async(IO) {
|
||||
chapter.getDisplayTitle(replaces, useReplace)
|
||||
})
|
||||
}
|
||||
}
|
||||
binding.rotateLoading.hide()
|
||||
adapter.setItems(data, adapter.diffCallBack)
|
||||
if (searchKey.isNullOrBlank() && mLayoutManager.findFirstVisibleItemPosition() < 0) {
|
||||
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
|
||||
|
||||
@@ -14,6 +14,16 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/ll_chapter_base_info" />
|
||||
|
||||
<io.legado.app.ui.widget.anima.RotateLoading
|
||||
android:id="@+id/rotate_loading"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="@id/recycler_view"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/recycler_view"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_chapter_base_info"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user