From a6418eaf9f79c43dc090721dcd7a1df93a582f2b Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 10 Feb 2022 20:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/toc/ChapterListAdapter.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 90c56609d..aeb38b2bc 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 @@ -19,6 +19,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) : RecyclerAdapter(context) { val cacheFileNames = hashSetOf() + val displayTileMap = hashMapOf() val diffCallBack = object : DiffUtil.ItemCallback() { override fun areItemsTheSame( @@ -47,6 +48,16 @@ class ChapterListAdapter(context: Context, val callback: Callback) : return ItemChapterListBinding.inflate(inflater, parent, false) } + private fun getDisplayTile(chapter: BookChapter): String { + var displayTile = displayTileMap[chapter.index] + if (displayTile != null) { + return displayTile + } + displayTile = chapter.getDisplayTitle() + displayTileMap[chapter.index] = displayTile + return displayTile + } + override fun convert( holder: ItemViewHolder, binding: ItemChapterListBinding, @@ -62,7 +73,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) : } else { tvChapterName.setTextColor(context.getCompatColor(R.color.primaryText)) } - tvChapterName.text = item.getDisplayTitle() + tvChapterName.text = getDisplayTile(item) if (item.isVolume) { //卷名,如第一卷 突出显示 tvChapterItem.setBackgroundColor(context.getCompatColor(R.color.btn_bg_press))