优化搜索结果展示

master
fengyuecanzhu 3 years ago
parent bb3873b0ec
commit 548fa8993f
  1. 7
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt
  2. 3
      app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/SearchWord1Holder.kt
  3. 2
      app/src/main/res/layout/activity_search_word.xml

@ -96,6 +96,12 @@ class SearchWordActivity : BaseActivity() {
override fun loadFinish(isEmpty: Boolean) { override fun loadFinish(isEmpty: Boolean) {
binding.fabSearchStop.visibility = View.GONE binding.fabSearchStop.visibility = View.GONE
binding.rpb.isAutoLoading = false binding.rpb.isAutoLoading = false
var sum = 0
adapter.items.forEach {
sum += it.searchWord2List.size
}
supportActionBar?.title = getString(R.string.search_word) + "(共" + adapter.itemSize +
"个章节," + sum + "条结果)"
} }
@Synchronized @Synchronized
@ -139,6 +145,7 @@ class SearchWordActivity : BaseActivity() {
private fun search() { private fun search() {
val keyword = binding.etSearchKey.text.toString() val keyword = binding.etSearchKey.text.toString()
if (keyword.isNotEmpty()) { if (keyword.isNotEmpty()) {
supportActionBar?.title = getString(R.string.search_word)
adapter.clear() adapter.clear()
binding.fabSearchStop.visibility = View.VISIBLE binding.fabSearchStop.visibility = View.VISIBLE
binding.rpb.isAutoLoading = true binding.rpb.isAutoLoading = true

@ -1,5 +1,6 @@
package xyz.fycz.myreader.ui.adapter.holder package xyz.fycz.myreader.ui.adapter.holder
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.view.View import android.view.View
@ -34,7 +35,7 @@ class SearchWord1Holder(var activity: AppCompatActivity) : ViewHolderImpl<Search
} }
override fun onBind(holder: RecyclerView.ViewHolder?, data: SearchWord1?, pos: Int) { override fun onBind(holder: RecyclerView.ViewHolder?, data: SearchWord1?, pos: Int) {
tvChapterTitle.text = data?.chapterTitle tvChapterTitle.text = String.format("%s(%d)", data?.chapterTitle, data?.searchWord2List?.size)
adapter = object : BaseListAdapter<SearchWord2>() { adapter = object : BaseListAdapter<SearchWord2>() {
override fun createViewHolder(viewType: Int): IViewHolder<SearchWord2> { override fun createViewHolder(viewType: Int): IViewHolder<SearchWord2> {
return SearchWord2Holder() return SearchWord2Holder()

@ -55,7 +55,7 @@
<xyz.fycz.myreader.widget.scroller.FastScrollRecyclerView <xyz.fycz.myreader.widget.scroller.FastScrollRecyclerView
android:id="@+id/rv_search_word1" android:id="@+id/rv_search_word1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:paddingHorizontal="10dp" android:paddingHorizontal="10dp"
tools:ignore="SpeakableTextPresentCheck" /> tools:ignore="SpeakableTextPresentCheck" />

Loading…
Cancel
Save