|
|
|
@ -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() { |
|
|
|
|