pull/32/head
kunfei 5 years ago
parent 8137846690
commit 0875f84eb1
  1. 16
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
  2. 2
      app/src/main/res/layout/dialog_change_source.xml

@ -20,8 +20,7 @@ class ChangeSourceDialog(val name: String, val author: String) : DialogFragment(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
tool_bar.inflateMenu(R.menu.search_view)
tool_bar.title = name
tool_bar.subtitle = getString(R.string.author_show, author)
showTitle()
initRecyclerView()
initSearchView()
}
@ -31,12 +30,25 @@ class ChangeSourceDialog(val name: String, val author: String) : DialogFragment(
dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}
private fun showTitle() {
tool_bar.title = name
tool_bar.subtitle = getString(R.string.author_show, author)
}
private fun initRecyclerView() {
recycler_view.layoutManager = LinearLayoutManager(context)
}
private fun initSearchView() {
val searchView = tool_bar.menu.findItem(R.id.menu_search).actionView as SearchView
searchView.setOnCloseListener {
showTitle()
false
}
searchView.setOnSearchClickListener {
tool_bar.title = ""
tool_bar.subtitle = ""
}
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
return false

@ -9,6 +9,8 @@
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:elevation="5dp"
app:displayHomeAsUp="false"
app:fitStatusBar="false"
app:layout_constraintTop_toTopOf="parent" />

Loading…
Cancel
Save