优化目录界面
This commit is contained in:
@@ -25,7 +25,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
|
|||||||
DiffRecyclerAdapter<BookChapter, ItemChapterListBinding>(context) {
|
DiffRecyclerAdapter<BookChapter, ItemChapterListBinding>(context) {
|
||||||
|
|
||||||
val cacheFileNames = hashSetOf<String>()
|
val cacheFileNames = hashSetOf<String>()
|
||||||
private val displayTitleMap = ConcurrentHashMap<Int, String>()
|
private val displayTitleMap = ConcurrentHashMap<String, String>()
|
||||||
|
|
||||||
override val diffItemCallback: DiffUtil.ItemCallback<BookChapter>
|
override val diffItemCallback: DiffUtil.ItemCallback<BookChapter>
|
||||||
get() = object : DiffUtil.ItemCallback<BookChapter>() {
|
get() = object : DiffUtil.ItemCallback<BookChapter>() {
|
||||||
@@ -80,8 +80,8 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
|
|||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
return@async
|
return@async
|
||||||
}
|
}
|
||||||
if (displayTitleMap[it.index] == null) {
|
if (displayTitleMap[it.url] == null) {
|
||||||
displayTitleMap[it.index] = it.getDisplayTitle(replaceRules, useReplace)
|
displayTitleMap[it.url] = it.getDisplayTitle(replaceRules, useReplace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,12 +92,12 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDisplayTile(chapter: BookChapter): String {
|
private fun getDisplayTile(chapter: BookChapter): String {
|
||||||
var displayTile = displayTitleMap[chapter.index]
|
var displayTile = displayTitleMap[chapter.url]
|
||||||
if (displayTile != null) {
|
if (displayTile != null) {
|
||||||
return displayTile
|
return displayTile
|
||||||
}
|
}
|
||||||
displayTile = chapter.getDisplayTitle(replaceRules, useReplace)
|
displayTile = chapter.getDisplayTitle(replaceRules, useReplace)
|
||||||
displayTitleMap[chapter.index] = displayTile
|
displayTitleMap[chapter.url] = displayTile
|
||||||
return displayTile
|
return displayTile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>() {
|
|||||||
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.menu_reverse_toc -> viewModel.reverseToc {
|
R.id.menu_reverse_toc -> viewModel.reverseToc {
|
||||||
viewModel.chapterListCallBack?.clearDisplayTitle()
|
|
||||||
viewModel.chapterListCallBack?.upChapterList(searchView?.query?.toString())
|
viewModel.chapterListCallBack?.upChapterList(searchView?.query?.toString())
|
||||||
setResult(RESULT_OK, Intent().apply {
|
setResult(RESULT_OK, Intent().apply {
|
||||||
putExtra("index", it.durChapterIndex)
|
putExtra("index", it.durChapterIndex)
|
||||||
|
|||||||
Reference in New Issue
Block a user