diff --git a/app/src/main/java/io/legado/app/ui/book/search/BookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/BookAdapter.kt new file mode 100644 index 000000000..7b018db40 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/search/BookAdapter.kt @@ -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(context, R.layout.item_text) { + + override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList) { + + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt new file mode 100644 index 000000000..7ceb93993 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt @@ -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(context, R.layout.item_text) { + + override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList) { + + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index 5e01ac820..5d3299611 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -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(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>? = null override fun onActivityCreated(savedInstanceState: Bundle?) { @@ -67,14 +70,30 @@ class SearchActivity : VMBaseActivity(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() { diff --git a/app/src/main/res/layout/activity_book_search.xml b/app/src/main/res/layout/activity_book_search.xml index 15e895b18..f231b65cb 100644 --- a/app/src/main/res/layout/activity_book_search.xml +++ b/app/src/main/res/layout/activity_book_search.xml @@ -50,7 +50,7 @@ android:text="@string/bookshelf" /> @@ -61,7 +61,7 @@ android:text="@string/searchHistory" />