优化
This commit is contained in:
@@ -58,7 +58,6 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
private val loadingChapters = arrayListOf<Int>()
|
||||
var simulatedChapterSize = 0
|
||||
var mCallback: Callback? = null
|
||||
var mFirstLoading = false
|
||||
var gameOver = false
|
||||
var mTopChapter: BookChapter? = null
|
||||
var preDownloadTask: Job? = null
|
||||
@@ -251,7 +250,6 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
loadingChapters.clear()
|
||||
simulatedChapterSize = 0
|
||||
mCallback = null
|
||||
mFirstLoading = false
|
||||
gameOver = false
|
||||
mTopChapter = null
|
||||
preDownloadTask?.cancel()
|
||||
@@ -292,10 +290,10 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
}.distinctUntilChanged().mapIndexed { index, src ->
|
||||
MangaContent(
|
||||
chapterSize = chapterSize,
|
||||
mChapterIndex = durChapterIndex.plus(1),
|
||||
mChapterIndex = durChapterIndex,
|
||||
nextChapterIndex = durChapterIndex.plus(1),
|
||||
mImageUrl = src,
|
||||
mDurChapterPos = index.plus(1),
|
||||
mDurChapterPos = index,
|
||||
mChapterName = chapterTitle
|
||||
)
|
||||
}.toList().apply {
|
||||
@@ -636,6 +634,5 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
fun noData()
|
||||
fun adjustmentProgress()
|
||||
fun sureNewProgress(progress: BookProgress)
|
||||
val chapterList: MutableList<Any>
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,6 @@ import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.storage.Backup
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
import io.legado.app.model.ReadManga
|
||||
import io.legado.app.model.ReadManga.mFirstLoading
|
||||
import io.legado.app.model.recyclerView.MangaContent
|
||||
import io.legado.app.model.recyclerView.ReaderLoading
|
||||
import io.legado.app.receiver.NetworkChangedListener
|
||||
@@ -154,7 +153,6 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, MangaViewModel>()
|
||||
binding.tvRetry.setOnClickListener {
|
||||
binding.llLoading.isVisible = true
|
||||
binding.llRetry.isGone = true
|
||||
mFirstLoading = false
|
||||
ReadManga.loadContent()
|
||||
}
|
||||
|
||||
@@ -216,11 +214,11 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, MangaViewModel>()
|
||||
try {
|
||||
val content = mAdapter.getCurrentList()[position]
|
||||
if (content is MangaContent) {
|
||||
ReadManga.durChapterPos = content.mDurChapterPos.minus(1)
|
||||
ReadManga.durChapterPos = content.mDurChapterPos
|
||||
upInfoBar(
|
||||
content.mChapterIndex,
|
||||
content.mChapterIndex + 1,
|
||||
content.chapterSize,
|
||||
content.mDurChapterPos,
|
||||
content.mDurChapterPos + 1,
|
||||
content.mDurChapterCount,
|
||||
content.mChapterName
|
||||
)
|
||||
@@ -270,18 +268,17 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, MangaViewModel>()
|
||||
override fun loadContentFinish(list: MutableList<Any>) {
|
||||
if (!this.isDestroyed) {
|
||||
setTitle(ReadManga.book?.name)
|
||||
val isEmpty = mAdapter.isEmpty()
|
||||
mAdapter.submitList(list) {
|
||||
if (!mFirstLoading) {
|
||||
if (list.size > 1) {
|
||||
binding.infobar.isVisible = true
|
||||
upInfoBar(
|
||||
ReadManga.durChapterIndex.plus(1),
|
||||
ReadManga.chapterSize,
|
||||
ReadManga.durChapterPos.plus(1),
|
||||
ReadManga.durChapterImageCount,
|
||||
ReadManga.chapterTitle
|
||||
)
|
||||
}
|
||||
if (isEmpty) {
|
||||
binding.infobar.isVisible = true
|
||||
upInfoBar(
|
||||
ReadManga.durChapterIndex.plus(1),
|
||||
ReadManga.chapterSize,
|
||||
ReadManga.durChapterPos.plus(1),
|
||||
ReadManga.durChapterImageCount,
|
||||
ReadManga.chapterTitle
|
||||
)
|
||||
|
||||
if (ReadManga.durChapterPos + 2 > mAdapter.getCurrentList().size - 3) {
|
||||
val nextIndex =
|
||||
@@ -298,7 +295,6 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, MangaViewModel>()
|
||||
|
||||
ReadManga.chapterChanged = false
|
||||
loadMoreView.visible()
|
||||
mFirstLoading = true
|
||||
loadMoreView.stopLoad()
|
||||
}
|
||||
}
|
||||
@@ -380,7 +376,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, MangaViewModel>()
|
||||
}
|
||||
|
||||
override fun loadFail(msg: String) {
|
||||
if (!mFirstLoading || ReadManga.chapterChanged) {
|
||||
if (mAdapter.isEmpty() || ReadManga.chapterChanged) {
|
||||
binding.llLoading.isGone = true
|
||||
binding.llRetry.isVisible = true
|
||||
binding.tvMsg.text = msg
|
||||
@@ -400,9 +396,6 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, MangaViewModel>()
|
||||
}
|
||||
}
|
||||
|
||||
override val chapterList: MutableList<Any>
|
||||
get() = mAdapter.getCurrentList()
|
||||
|
||||
override fun onDestroy() {
|
||||
ReadManga.unregister()
|
||||
super.onDestroy()
|
||||
|
||||
@@ -63,6 +63,10 @@ class MangaAdapter(private val context: Context) :
|
||||
|
||||
fun getCurrentList() = mDiffer.currentList
|
||||
|
||||
fun isEmpty() = mDiffer.currentList.isEmpty()
|
||||
|
||||
fun isNotEmpty() = !isEmpty()
|
||||
|
||||
//全部替换数据
|
||||
fun submitList(contents: MutableList<Any>, runnable: Runnable) {
|
||||
val list = if (ReadManga.chapterChanged) {
|
||||
|
||||
Reference in New Issue
Block a user