优化
This commit is contained in:
@@ -21,7 +21,7 @@ import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.help.globalExecutor
|
||||
import io.legado.app.model.webBook.WebBook
|
||||
import io.legado.app.ui.book.manga.entities.MangaChapter
|
||||
import io.legado.app.ui.book.manga.entities.MangaContentData
|
||||
import io.legado.app.ui.book.manga.entities.MangaContent
|
||||
import io.legado.app.ui.book.manga.entities.MangaPage
|
||||
import io.legado.app.ui.book.manga.entities.ReaderLoading
|
||||
import io.legado.app.utils.mapIndexed
|
||||
@@ -48,7 +48,6 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
val executor = globalExecutor
|
||||
var durChapterIndex = 0 //章节位置
|
||||
var chapterSize = 0//总章节
|
||||
var durChapterImageCount = 0
|
||||
var durChapterPos = 0
|
||||
var prevMangaChapter: MangaChapter? = null
|
||||
var curMangaChapter: MangaChapter? = null
|
||||
@@ -65,7 +64,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
val downloadScope = CoroutineScope(SupervisorJob() + IO)
|
||||
val preDownloadSemaphore = Semaphore(2)
|
||||
var rateLimiter = ConcurrentRateLimiter(null)
|
||||
val mangaContents get() = buildContentList()
|
||||
val mangaContents get() = buildMangaContent()
|
||||
val hasNextChapter get() = durChapterIndex < simulatedChapterSize - 1
|
||||
|
||||
fun resetData(book: Book) {
|
||||
@@ -216,7 +215,6 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
mCallback?.loadFail("正文没有图片")
|
||||
return
|
||||
}
|
||||
durChapterImageCount = mangaChapter.imageCount
|
||||
curMangaChapter = mangaChapter
|
||||
mCallback?.upContent()
|
||||
}
|
||||
@@ -240,20 +238,24 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildContentList(): MangaContentData {
|
||||
private fun buildMangaContent(): MangaContent {
|
||||
val list = arrayListOf<Any>()
|
||||
var pos = durChapterPos + 1
|
||||
var curFinish = false
|
||||
var nextFinish = false
|
||||
prevMangaChapter?.let {
|
||||
pos += it.contents.size
|
||||
list.addAll(it.contents)
|
||||
}
|
||||
curMangaChapter?.let {
|
||||
curFinish = true
|
||||
list.addAll(it.contents)
|
||||
}
|
||||
nextMangaChapter?.let {
|
||||
nextFinish = true
|
||||
list.addAll(it.contents)
|
||||
}
|
||||
return MangaContentData(pos, list, curMangaChapter != null, nextMangaChapter != null)
|
||||
return MangaContent(pos, list, curFinish, nextFinish)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -268,13 +268,15 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
val curFinish = data.curFinish
|
||||
val nextFinish = data.nextFinish
|
||||
mAdapter.submitList(list) {
|
||||
binding.mangaMenu.upSeekBar(ReadManga.durChapterPos, ReadManga.durChapterImageCount)
|
||||
if (loadingViewVisible && curFinish) {
|
||||
binding.infobar.isVisible = true
|
||||
upInfoBar(list[pos])
|
||||
binding.mRecyclerManga.scrollToPosition(pos)
|
||||
mLayoutManager.scrollToPositionWithOffset(pos, 0)
|
||||
binding.flLoading.isGone = true
|
||||
loadMoreView.visible()
|
||||
binding.mangaMenu.upSeekBar(
|
||||
ReadManga.durChapterPos, ReadManga.curMangaChapter!!.imageCount
|
||||
)
|
||||
}
|
||||
|
||||
if (curFinish) {
|
||||
@@ -757,7 +759,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
}
|
||||
}
|
||||
if (pos > -1) {
|
||||
binding.mRecyclerManga.scrollToPosition(pos)
|
||||
mLayoutManager.scrollToPositionWithOffset(pos, 0)
|
||||
upInfoBar(mAdapter.getItem(pos))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package io.legado.app.ui.book.manga.entities
|
||||
|
||||
data class MangaContentData(
|
||||
data class MangaContent(
|
||||
val pos: Int,
|
||||
val contents: List<Any>,
|
||||
val curFinish: Boolean,
|
||||
@@ -243,8 +243,10 @@ class MangaMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
callBack.skipToPage(seekBar.progress)
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
callBack.skipToPage(seekBar.progress)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user