This commit is contained in:
Xwite 2023-03-11 13:12:31 +08:00
parent 7837717371
commit b886a85326
4 changed files with 7 additions and 5 deletions

View File

@ -79,10 +79,10 @@ class EpubFile(var book: Book) {
}
return field
}
private var epubBookContents: List<Resource>?
private var epubBookContents: List<Resource>? = null
get() {
if (field == null || fileDescriptor == null) {
field = epubBook.contents
field = epubBook?.contents
}
return field
}
@ -153,6 +153,7 @@ class EpubFile(var book: Book) {
val includeNextChapterResource = !endFragmentId.isNullOrBlank()
/*一些书籍依靠href索引的resource会包含多个章节需要依靠fragmentId来截取到当前章节的内容*/
/*注:这里较大增加了内容加载的时间所以首次获取内容后可存储到本地cache减少重复加载*/
epubBookContents ?: return null
for (res in epubBookContents) {
if (!findChapterFirstSource) {
if (currentChapterFirstResourceHref != res.href) continue

View File

@ -7,7 +7,7 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.Lifecycle.repeatOnLifecycle
import androidx.lifecycle.repeatOnLifecycle
import androidx.lifecycle.Lifecycle.State.STARTED
import androidx.recyclerview.widget.GridLayoutManager
import io.legado.app.R
@ -20,6 +20,7 @@ import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
/**
* 换封面

View File

@ -10,7 +10,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.Lifecycle.repeatOnLifecycle
import androidx.lifecycle.repeatOnLifecycle
import androidx.lifecycle.Lifecycle.State.STARTED
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

View File

@ -10,7 +10,7 @@ import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.Lifecycle.repeatOnLifecycle
import androidx.lifecycle.repeatOnLifecycle
import androidx.lifecycle.Lifecycle.State.STARTED
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView