|
|
@ -15,9 +15,9 @@ import com.google.android.material.tabs.TabLayout |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.databinding.ActivityChapterListBinding |
|
|
|
import io.legado.app.databinding.ActivityChapterListBinding |
|
|
|
import io.legado.app.lib.theme.ATH |
|
|
|
|
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
import io.legado.app.lib.theme.primaryTextColor |
|
|
|
import io.legado.app.lib.theme.primaryTextColor |
|
|
|
|
|
|
|
import io.legado.app.utils.applyTint |
|
|
|
import io.legado.app.utils.gone |
|
|
|
import io.legado.app.utils.gone |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
import io.legado.app.utils.visible |
|
|
|
import io.legado.app.utils.visible |
|
|
@ -45,29 +45,30 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>() { |
|
|
|
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { |
|
|
|
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { |
|
|
|
menuInflater.inflate(R.menu.book_toc, menu) |
|
|
|
menuInflater.inflate(R.menu.book_toc, menu) |
|
|
|
val search = menu.findItem(R.id.menu_search) |
|
|
|
val search = menu.findItem(R.id.menu_search) |
|
|
|
searchView = search.actionView as SearchView |
|
|
|
searchView = (search.actionView as SearchView).apply { |
|
|
|
ATH.setTint(searchView!!, primaryTextColor) |
|
|
|
applyTint(primaryTextColor) |
|
|
|
searchView?.maxWidth = resources.displayMetrics.widthPixels |
|
|
|
maxWidth = resources.displayMetrics.widthPixels |
|
|
|
searchView?.onActionViewCollapsed() |
|
|
|
onActionViewCollapsed() |
|
|
|
searchView?.setOnCloseListener { |
|
|
|
setOnCloseListener { |
|
|
|
tabLayout.visible() |
|
|
|
tabLayout.visible() |
|
|
|
false |
|
|
|
false |
|
|
|
} |
|
|
|
|
|
|
|
searchView?.setOnSearchClickListener { tabLayout.gone() } |
|
|
|
|
|
|
|
searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener { |
|
|
|
|
|
|
|
override fun onQueryTextSubmit(query: String): Boolean { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
setOnSearchClickListener { tabLayout.gone() } |
|
|
|
|
|
|
|
setOnQueryTextListener(object : SearchView.OnQueryTextListener { |
|
|
|
|
|
|
|
override fun onQueryTextSubmit(query: String): Boolean { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onQueryTextChange(newText: String): Boolean { |
|
|
|
override fun onQueryTextChange(newText: String): Boolean { |
|
|
|
if (tabLayout.selectedTabPosition == 1) { |
|
|
|
if (tabLayout.selectedTabPosition == 1) { |
|
|
|
viewModel.startBookmarkSearch(newText) |
|
|
|
viewModel.startBookmarkSearch(newText) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
viewModel.startChapterListSearch(newText) |
|
|
|
viewModel.startChapterListSearch(newText) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
return super.onCompatCreateOptionsMenu(menu) |
|
|
|
return super.onCompatCreateOptionsMenu(menu) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|