pull/34/head
kunfei 5 years ago
parent 604361c2d2
commit 425e40b167
  1. 32
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  2. 5
      app/src/main/res/layout/fragment_find_book.xml
  3. 1
      app/src/main/res/values/strings.xml

@ -1,10 +1,7 @@
package io.legado.app.ui.main.explore
import android.os.Bundle
import android.view.Menu
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.SearchView
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App
@ -15,10 +12,10 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.ui.book.source.edit.SourceEditActivity
import io.legado.app.ui.explore.ExploreShowActivity
import io.legado.app.utils.getCompatDrawable
import io.legado.app.utils.getViewModel
import io.legado.app.utils.startActivity
import kotlinx.android.synthetic.main.fragment_find_book.*
import kotlinx.android.synthetic.main.view_search.*
import kotlinx.android.synthetic.main.view_title_bar.*
@ -29,33 +26,20 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_find_
private lateinit var adapter: ExploreAdapter
private lateinit var linearLayoutManager: LinearLayoutManager
private var searchView: SearchView? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
setSupportToolbar(toolbar)
initSearchView()
initRecyclerView()
initData()
}
override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.search_view, menu)
val search = menu.findItem(R.id.menu_search)
searchView = search.actionView as SearchView
val bottom =
searchView?.findViewById<View>(androidx.appcompat.R.id.search_button) as? AppCompatImageView
bottom?.setImageDrawable(getCompatDrawable(R.drawable.ic_screen))
ATH.setTint(searchView!!, primaryTextColor)
searchView?.maxWidth = resources.displayMetrics.widthPixels
searchView?.onActionViewCollapsed()
searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
return false
}
override fun onQueryTextChange(newText: String): Boolean {
return false
}
})
private fun initSearchView() {
ATH.setTint(search_view, primaryTextColor)
search_view.onActionViewExpanded()
search_view.isSubmitButtonEnabled = true
search_view.queryHint = getString(R.string.screen_find)
search_view.clearFocus()
}
private fun initRecyclerView() {

@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:attachToActivity="false"
app:contentLayout="@layout/view_search"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/find" />

@ -506,5 +506,6 @@
<string name="web_dav_account_s">输入你的WebDav账号</string>
<string name="rss_source">订阅源</string>
<string name="screen">筛选</string>
<string name="screen_find">筛选发现</string>
</resources>

Loading…
Cancel
Save