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