正文搜索百分比 #272
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user