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?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
tool_bar.inflateMenu(R.menu.search_view) tool_bar.inflateMenu(R.menu.search_view)
tool_bar.title = name showTitle()
tool_bar.subtitle = getString(R.string.author_show, author)
initRecyclerView() initRecyclerView()
initSearchView() 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) 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() { private fun initRecyclerView() {
recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.layoutManager = LinearLayoutManager(context)
} }
private fun initSearchView() { private fun initSearchView() {
val searchView = tool_bar.menu.findItem(R.id.menu_search).actionView as SearchView 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 { searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean { override fun onQueryTextSubmit(query: String?): Boolean {
return false return false

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

Loading…
Cancel
Save