正文搜索百分比 #272
This commit is contained in:
2 files changed
+46
-7
No files matched your search
@@ -108,6 +108,7 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
"${context.getString(R.string.search_content_size)}: ${searchResultList.size}"
|
"${context.getString(R.string.search_content_size)}: ${searchResultList.size}"
|
||||||
binding.tvCurrentChapter.text = "当前章节: ${it.title}"
|
binding.tvCurrentChapter.text = "当前章节: ${it.title}"
|
||||||
}
|
}
|
||||||
|
updateSearchProgress()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateSearchResultIndex(updateIndex: Int) {
|
fun updateSearchResultIndex(updateIndex: Int) {
|
||||||
@@ -117,6 +118,17 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
updateIndex >= searchResultList.size -> searchResultList.size - 1
|
updateIndex >= searchResultList.size -> searchResultList.size - 1
|
||||||
else -> updateIndex
|
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 {
|
private fun bindEvent() = binding.run {
|
||||||
|
|||||||
@@ -63,14 +63,41 @@
|
|||||||
app:cardBackgroundColor="?attr/colorSecondaryContainer"
|
app:cardBackgroundColor="?attr/colorSecondaryContainer"
|
||||||
android:layout_marginHorizontal="16dp">
|
android:layout_marginHorizontal="16dp">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tv_current_search_info"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?attr/colorOnSecondaryContainer"
|
android:orientation="horizontal">
|
||||||
android:padding="8dp"
|
<TextView
|
||||||
android:singleLine="true"
|
android:id="@+id/tv_current_search_info"
|
||||||
android:textSize="18sp" />
|
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>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user