正文搜索百分比 #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 {
|
||||
|
||||
@@ -63,14 +63,41 @@
|
||||
app:cardBackgroundColor="?attr/colorSecondaryContainer"
|
||||
android:layout_marginHorizontal="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_current_search_info"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:textColor="?attr/colorOnSecondaryContainer"
|
||||
android:padding="8dp"
|
||||
android:singleLine="true"
|
||||
android:textSize="18sp" />
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/tv_current_search_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/colorOnSecondaryContainer"
|
||||
android:textStyle="bold"
|
||||
android:layout_margin="8dp"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/default_version"
|
||||
android:textColor="?attr/colorOnSecondaryContainer"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:singleLine="true"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSearchProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/colorOnSecondaryContainer"
|
||||
android:singleLine="true"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user