From b0f6312ebb5c0f2200de2ee15beab3acbb7df368 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 6 Mar 2022 21:52:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=AE=E5=BD=95=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/toc/ChapterListAdapter.kt | 10 +++++----- .../main/java/io/legado/app/ui/book/toc/TocActivity.kt | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt index c882c5d2f..83a23a685 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt @@ -25,7 +25,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) : DiffRecyclerAdapter(context) { val cacheFileNames = hashSetOf() - private val displayTitleMap = ConcurrentHashMap() + private val displayTitleMap = ConcurrentHashMap() override val diffItemCallback: DiffUtil.ItemCallback get() = object : DiffUtil.ItemCallback() { @@ -80,8 +80,8 @@ class ChapterListAdapter(context: Context, val callback: Callback) : if (!isActive) { return@async } - if (displayTitleMap[it.index] == null) { - displayTitleMap[it.index] = it.getDisplayTitle(replaceRules, useReplace) + if (displayTitleMap[it.url] == null) { + displayTitleMap[it.url] = it.getDisplayTitle(replaceRules, useReplace) } } } @@ -92,12 +92,12 @@ class ChapterListAdapter(context: Context, val callback: Callback) : } private fun getDisplayTile(chapter: BookChapter): String { - var displayTile = displayTitleMap[chapter.index] + var displayTile = displayTitleMap[chapter.url] if (displayTile != null) { return displayTile } displayTile = chapter.getDisplayTitle(replaceRules, useReplace) - displayTitleMap[chapter.index] = displayTile + displayTitleMap[chapter.url] = displayTile return displayTile } diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt index f0134f914..e937a3176 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt @@ -83,7 +83,6 @@ class TocActivity : VMBaseActivity() { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_reverse_toc -> viewModel.reverseToc { - viewModel.chapterListCallBack?.clearDisplayTitle() viewModel.chapterListCallBack?.upChapterList(searchView?.query?.toString()) setResult(RESULT_OK, Intent().apply { putExtra("index", it.durChapterIndex)