pull/36/head
kunfei 5 years ago
parent f915eb8dcb
commit abc9c2f196
  1. 15
      app/src/main/java/io/legado/app/ui/book/search/BookAdapter.kt
  2. 16
      app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt
  3. 21
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  4. 4
      app/src/main/res/layout/activity_book_search.xml

@ -0,0 +1,15 @@
package io.legado.app.ui.book.search
import android.content.Context
import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
class BookAdapter(context: Context) :
SimpleRecyclerAdapter<String>(context, R.layout.item_text) {
override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) {
}
}

@ -0,0 +1,16 @@
package io.legado.app.ui.book.search
import android.content.Context
import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
class HistoryKeyAdapter(context: Context) :
SimpleRecyclerAdapter<String>(context, R.layout.item_text) {
override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) {
}
}

@ -7,6 +7,7 @@ import androidx.lifecycle.Observer
import androidx.paging.LivePagedListBuilder
import androidx.paging.PagedList
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -29,6 +30,8 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
get() = getViewModel(SearchViewModel::class.java)
private lateinit var adapter: SearchAdapter
private lateinit var bookAdapter: BookAdapter
private lateinit var historyKeyAdapter: HistoryKeyAdapter
private var searchBookData: LiveData<PagedList<SearchShow>>? = null
override fun onActivityCreated(savedInstanceState: Bundle?) {
@ -67,14 +70,30 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
return false
}
})
fb_stop.onClick { viewModel.stop() }
search_view.setOnQueryTextFocusChangeListener { v, hasFocus ->
if (hasFocus) {
ll_history.visible()
} else {
ll_history.invisible()
}
}
}
private fun initRecyclerView() {
ATH.applyEdgeEffectColor(recycler_view)
ATH.applyEdgeEffectColor(rv_bookshelf_search)
ATH.applyEdgeEffectColor(rv_history_key)
bookAdapter = BookAdapter(this)
rv_bookshelf_search.layoutManager =
LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)
rv_bookshelf_search.adapter = bookAdapter
historyKeyAdapter = HistoryKeyAdapter(this)
rv_history_key.layoutManager = LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)
rv_history_key.adapter = historyKeyAdapter
adapter = SearchAdapter(this)
recycler_view.layoutManager = LinearLayoutManager(this)
recycler_view.adapter = adapter
fb_stop.onClick { viewModel.stop() }
}
private fun initData() {

@ -50,7 +50,7 @@
android:text="@string/bookshelf" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_bookshelf"
android:id="@+id/rv_bookshelf_search"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@ -61,7 +61,7 @@
android:text="@string/searchHistory" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_history"
android:id="@+id/rv_history_key"
android:layout_width="wrap_content"
android:layout_height="match_parent" />

Loading…
Cancel
Save