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))