优化
This commit is contained in:
@@ -6,6 +6,9 @@ import io.legado.app.data.entities.BaseSource
|
||||
import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.data.entities.RssSource
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.model.AudioPlay
|
||||
import io.legado.app.model.ReadBook
|
||||
import io.legado.app.model.ReadManga
|
||||
import io.legado.app.utils.EncoderUtils
|
||||
import io.legado.app.utils.NetworkUtils
|
||||
import io.legado.app.utils.splitNotBlank
|
||||
@@ -27,6 +30,13 @@ object SourceHelp {
|
||||
|
||||
fun getSource(key: String?): BaseSource? {
|
||||
key ?: return null
|
||||
if (ReadBook.bookSource?.bookSourceUrl == key) {
|
||||
return ReadBook.bookSource
|
||||
} else if (AudioPlay.bookSource?.bookSourceUrl == key) {
|
||||
return AudioPlay.bookSource
|
||||
} else if (ReadManga.bookSource?.bookSourceUrl == key) {
|
||||
return ReadManga.bookSource
|
||||
}
|
||||
return appDb.bookSourceDao.getBookSource(key)
|
||||
?: appDb.rssSourceDao.getByKey(key)
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
}
|
||||
|
||||
-1, 1 -> {
|
||||
if (content == null || content.isEmpty()) {
|
||||
if (content == null || (!chapter.isVolume && content.isEmpty())) {
|
||||
return
|
||||
}
|
||||
val mangaChapter = getManageChapter(chapter, content)
|
||||
@@ -597,14 +597,14 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
it.imageCount = imageCount
|
||||
}
|
||||
|
||||
if (AppConfig.hideMangaTitle) {
|
||||
if (AppConfig.hideMangaTitle && imageCount > 0) {
|
||||
return MangaChapter(chapter, list, imageCount)
|
||||
}
|
||||
|
||||
val pages = mutableListOf<BaseMangaPage>()
|
||||
|
||||
if (imageCount == 0 && chapter.isVolume) {
|
||||
pages.add(ReaderLoading(chapter.index, -1, chapter.title))
|
||||
pages.add(ReaderLoading(chapter.index, -1, chapter.title, true))
|
||||
} else {
|
||||
pages.add(ReaderLoading(chapter.index, -1, "阅读 ${chapter.title}"))
|
||||
pages.addAll(list)
|
||||
|
||||
@@ -17,8 +17,6 @@ import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.PagerSnapHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader
|
||||
import com.bumptech.glide.request.target.Target.SIZE_ORIGINAL
|
||||
@@ -50,6 +48,7 @@ import io.legado.app.ui.book.manga.config.MangaFooterSettingDialog
|
||||
import io.legado.app.ui.book.manga.entities.BaseMangaPage
|
||||
import io.legado.app.ui.book.manga.entities.MangaPage
|
||||
import io.legado.app.ui.book.manga.recyclerview.MangaAdapter
|
||||
import io.legado.app.ui.book.manga.recyclerview.MangaLayoutManager
|
||||
import io.legado.app.ui.book.manga.recyclerview.ScrollTimer
|
||||
import io.legado.app.ui.book.read.MangaMenu
|
||||
import io.legado.app.ui.book.read.ReadBookActivity.Companion.RESULT_DELETED
|
||||
@@ -82,7 +81,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
MangaColorFilterDialog.Callback, ScrollTimer.ScrollCallback {
|
||||
|
||||
private val mLayoutManager by lazy {
|
||||
LinearLayoutManager(this)
|
||||
MangaLayoutManager(this)
|
||||
}
|
||||
private val mAdapter: MangaAdapter by lazy {
|
||||
MangaAdapter(this)
|
||||
@@ -206,7 +205,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
setPreScrollListener { _, _, _, position ->
|
||||
if (mAdapter.isNotEmpty()) {
|
||||
val item = mAdapter.getItem(position)
|
||||
if (item is MangaPage) {
|
||||
if (item is BaseMangaPage) {
|
||||
if (ReadManga.durChapterIndex < item.chapterIndex) {
|
||||
ReadManga.moveToNextChapter()
|
||||
} else if (ReadManga.durChapterIndex > item.chapterIndex) {
|
||||
@@ -215,25 +214,13 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
ReadManga.durChapterPos = item.index
|
||||
ReadManga.curPageChanged()
|
||||
}
|
||||
binding.mangaMenu.upSeekBar(item.index, item.imageCount)
|
||||
upInfoBar(item)
|
||||
if (item is MangaPage) {
|
||||
binding.mangaMenu.upSeekBar(item.index, item.imageCount)
|
||||
upInfoBar(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(
|
||||
recyclerView: RecyclerView,
|
||||
newState: Int
|
||||
) {
|
||||
if (newState == SCROLL_STATE_IDLE &&
|
||||
!canScroll(1) &&
|
||||
ReadManga.hasNextChapter && !loadMoreView.isLoading
|
||||
) {
|
||||
loadMoreView.startLoad()
|
||||
ReadManga.moveToNextChapter()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
binding.webtoonFrame.run {
|
||||
onTouchMiddle {
|
||||
|
||||
@@ -4,5 +4,6 @@ data class ReaderLoading(
|
||||
override val chapterIndex: Int = 0,
|
||||
override val index: Int = 0,
|
||||
val mMessage: String? = null,
|
||||
val isVolume: Boolean = false
|
||||
) : BaseMangaPage
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.legado.app.model.ReadManga
|
||||
import io.legado.app.ui.book.manga.config.MangaColorFilterConfig
|
||||
import io.legado.app.ui.book.manga.entities.MangaPage
|
||||
import io.legado.app.ui.book.manga.entities.ReaderLoading
|
||||
import io.legado.app.utils.dpToPx
|
||||
|
||||
|
||||
class MangaAdapter(private val context: Context) :
|
||||
@@ -124,6 +125,13 @@ class MangaAdapter(private val context: Context) :
|
||||
fun onBind(item: ReaderLoading) {
|
||||
val message = item.mMessage
|
||||
binding.text.text = message
|
||||
itemView.updateLayoutParams {
|
||||
height = if (item.isVolume) {
|
||||
MATCH_PARENT
|
||||
} else {
|
||||
96.dpToPx()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package io.legado.app.ui.book.manga.recyclerview
|
||||
|
||||
import android.content.Context
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class MangaLayoutManager(context: Context) :
|
||||
LinearLayoutManager(context) {
|
||||
|
||||
private val extraLayoutSpace = context.resources.displayMetrics.heightPixels * 3 / 4
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun getExtraLayoutSpace(state: RecyclerView.State?): Int {
|
||||
return extraLayoutSpace
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user