正文搜索百分比 #272

This commit is contained in:
HapeLee
2025-11-12 20:48:29 +08:00
parent 22de5c26af
commit 5fbdcf54d8
2 changed files with 46 additions and 7 deletions
@@ -108,6 +108,7 @@ class SearchMenu @JvmOverloads constructor(
"${context.getString(R.string.search_content_size)}: ${searchResultList.size}"
binding.tvCurrentChapter.text = "当前章节: ${it.title}"
}
updateSearchProgress()
}
fun updateSearchResultIndex(updateIndex: Int) {
@@ -117,6 +118,17 @@ class SearchMenu @JvmOverloads constructor(
updateIndex >= searchResultList.size -> searchResultList.size - 1
else -> updateIndex
}
updateSearchProgress()
}
private fun updateSearchProgress() {
val total = searchResultList.size
if (total == 0) {
binding.tvSearchProgress.text = "0%"
} else {
val progress = ((currentSearchResultIndex + 1) * 100 / total)
binding.tvSearchProgress.text = "$progress%"
}
}
private fun bindEvent() = binding.run {