diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index e3ccd0692..098c27b28 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -253,29 +253,28 @@ object ReadBook : CoroutineScope by MainScope() { syncSuccessAction: (() -> Unit)? = null ) { if (!AppConfig.syncBookProgress) return - book?.let { - Coroutine.async { - AppWebDav.getBookProgress(it) - }.onError { - AppLog.put("拉取阅读进度失败", it) - }.onSuccess { progress -> - if (progress == null || progress.durChapterIndex < it.durChapterIndex || - (progress.durChapterIndex == it.durChapterIndex - && progress.durChapterPos < it.durChapterPos) - ) { - // 服务器没有进度或者进度比服务器快,上传现有进度 - Coroutine.async { - AppWebDav.uploadBookProgress(BookProgress(it), uploadSuccessAction) - it.update() - } - } else if (progress.durChapterIndex > it.durChapterIndex || - progress.durChapterPos > it.durChapterPos - ) { - // 进度比服务器慢,执行传入动作 - newProgressAction?.invoke(progress) - } else { - syncSuccessAction?.invoke() + val book = book ?: return + Coroutine.async { + AppWebDav.getBookProgress(book) + }.onError { + AppLog.put("拉取阅读进度失败", it) + }.onSuccess { progress -> + if (progress == null || progress.durChapterIndex < book.durChapterIndex || + (progress.durChapterIndex == book.durChapterIndex + && progress.durChapterPos < book.durChapterPos) + ) { + // 服务器没有进度或者进度比服务器快,上传现有进度 + Coroutine.async { + AppWebDav.uploadBookProgress(BookProgress(book), uploadSuccessAction) + book.update() } + } else if (progress.durChapterIndex > book.durChapterIndex || + progress.durChapterPos > book.durChapterPos + ) { + // 进度比服务器慢,执行传入动作 + newProgressAction?.invoke(progress) + } else { + syncSuccessAction?.invoke() } } } diff --git a/app/src/main/java/io/legado/app/model/ReadManga.kt b/app/src/main/java/io/legado/app/model/ReadManga.kt index 24ec87846..832c0174a 100644 --- a/app/src/main/java/io/legado/app/model/ReadManga.kt +++ b/app/src/main/java/io/legado/app/model/ReadManga.kt @@ -211,7 +211,7 @@ object ReadManga : CoroutineScope by MainScope() { return } val mangaChapter = getManageChapter(chapter, content) - if (mangaChapter.imageCount == 0) { + if (mangaChapter.imageCount == 0 && !chapter.isVolume) { mCallback?.loadFail("正文没有图片") return } @@ -224,7 +224,7 @@ object ReadManga : CoroutineScope by MainScope() { return } val mangaChapter = getManageChapter(chapter, content) - if (mangaChapter.imageCount == 0) { + if (mangaChapter.imageCount == 0 && !chapter.isVolume) { return } @@ -488,29 +488,28 @@ object ReadManga : CoroutineScope by MainScope() { syncSuccessAction: (() -> Unit)? = null, ) { if (!AppConfig.syncBookProgress) return - book?.let { - Coroutine.async { - AppWebDav.getBookProgress(it) - }.onError { - AppLog.put("拉取阅读进度失败", it) - }.onSuccess { progress -> - if (progress == null || progress.durChapterIndex < it.durChapterIndex || - (progress.durChapterIndex == it.durChapterIndex - && progress.durChapterPos < it.durChapterPos) - ) { - // 服务器没有进度或者进度比服务器快,上传现有进度 - Coroutine.async { - AppWebDav.uploadBookProgress(BookProgress(it), uploadSuccessAction) - it.update() - } - } else if (progress.durChapterIndex > it.durChapterIndex || - progress.durChapterPos > it.durChapterPos - ) { - // 进度比服务器慢,执行传入动作 - newProgressAction?.invoke(progress) - } else { - syncSuccessAction?.invoke() + val book = book ?: return + Coroutine.async { + AppWebDav.getBookProgress(book) + }.onError { + AppLog.put("拉取阅读进度失败", it) + }.onSuccess { progress -> + if (progress == null || progress.durChapterIndex < book.durChapterIndex || + (progress.durChapterIndex == book.durChapterIndex + && progress.durChapterPos < book.durChapterPos) + ) { + // 服务器没有进度或者进度比服务器快,上传现有进度 + Coroutine.async { + AppWebDav.uploadBookProgress(BookProgress(book), uploadSuccessAction) + book.update() } + } else if (progress.durChapterIndex > book.durChapterIndex || + progress.durChapterPos > book.durChapterPos + ) { + // 进度比服务器慢,执行传入动作 + newProgressAction?.invoke(progress) + } else { + syncSuccessAction?.invoke() } } } @@ -591,12 +590,21 @@ object ReadManga : CoroutineScope by MainScope() { it.imageCount = imageCount } - val contentList = mutableListOf() - contentList.add(ReaderLoading(chapter.index, -1, "阅读 ${chapter.title}")) - contentList.addAll(list) - contentList.add(ReaderLoading(chapter.index, imageCount, "已读完 ${chapter.title}")) + if (AppConfig.hideMangaTitle) { + return MangaChapter(chapter, list, imageCount) + } - return MangaChapter(chapter, contentList, imageCount) + val pages = mutableListOf() + + if (imageCount == 0 && chapter.isVolume) { + pages.add(ReaderLoading(chapter.index, -1, chapter.title)) + } else { + pages.add(ReaderLoading(chapter.index, -1, "阅读 ${chapter.title}")) + pages.addAll(list) + pages.add(ReaderLoading(chapter.index, imageCount, "已读完 ${chapter.title}")) + } + + return MangaChapter(chapter, pages, imageCount) } interface Callback { diff --git a/app/src/main/java/io/legado/app/ui/book/manga/ReadMangaActivity.kt b/app/src/main/java/io/legado/app/ui/book/manga/ReadMangaActivity.kt index 539c7b377..a4adcf7cb 100644 --- a/app/src/main/java/io/legado/app/ui/book/manga/ReadMangaActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/manga/ReadMangaActivity.kt @@ -17,6 +17,8 @@ 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 @@ -191,7 +193,6 @@ class ReadMangaActivity : VMBaseActivity { item.isChecked = !item.isChecked AppConfig.hideMangaTitle = item.isChecked - mAdapter.setHideTitle(item.isChecked) + ReadManga.loadContent() } } return super.onCompatOptionsItemSelected(item) diff --git a/app/src/main/java/io/legado/app/ui/book/manga/recyclerview/MangaAdapter.kt b/app/src/main/java/io/legado/app/ui/book/manga/recyclerview/MangaAdapter.kt index 882738408..e682d38a1 100644 --- a/app/src/main/java/io/legado/app/ui/book/manga/recyclerview/MangaAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/manga/recyclerview/MangaAdapter.kt @@ -1,6 +1,5 @@ package io.legado.app.ui.book.manga.recyclerview -import android.annotation.SuppressLint import android.content.Context import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter @@ -28,7 +27,6 @@ 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.ui.widget.anima.explosion_field.Utils class MangaAdapter(private val context: Context) : @@ -43,7 +41,6 @@ class MangaAdapter(private val context: Context) : } var isHorizontal = false - private var hideTitle = false private val mDiffCallback: DiffUtil.ItemCallback = object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: Any, newItem: Any): Boolean { @@ -128,9 +125,6 @@ class MangaAdapter(private val context: Context) : fun onBind(item: ReaderLoading) { val message = item.mMessage binding.text.text = message - binding.root.updateLayoutParams { - height = if (hideTitle) 0 else Utils.dp2Px(96) - } } } @@ -238,14 +232,9 @@ class MangaAdapter(private val context: Context) : return null } - @SuppressLint("NotifyDataSetChanged") fun setMangaImageColorFilter(config: MangaColorFilterConfig) { mConfig = config notifyItemRangeChanged(0, itemCount) } - fun setHideTitle(hide: Boolean) { - this.hideTitle=hide - notifyItemRangeChanged(0, itemCount) - } } \ No newline at end of file