aboutsummaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
Diffstat (limited to 'library')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt14
1 files changed, 14 insertions, 0 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
index bfeed52..d7ff634 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
@@ -179,6 +179,7 @@ class SearchView @JvmOverloads constructor(
init {
View.inflate(context, R.layout.kau_search_view, this)
+ z = 99f
iconNav.setSearchIcon(configs.navIcon)
iconClear.setSearchIcon(configs.clearIcon).setOnClickListener {
editText.text.clear()
@@ -186,6 +187,7 @@ class SearchView @JvmOverloads constructor(
tintForeground(configs.foregroundColor)
tintBackground(configs.backgroundColor)
with(recycler) {
+ isNestedScrollingEnabled = false
layoutManager = LinearLayoutManager(context)
addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
@@ -264,6 +266,18 @@ class SearchView @JvmOverloads constructor(
}
/**
+ * Handle a back press event
+ * Returns true if back press is consumed, false otherwise
+ */
+ fun onBackPressed(): Boolean {
+ if (isOpen && menuItem != null) {
+ revealClose()
+ return true
+ }
+ return false
+ }
+
+ /**
* Tint foreground attributes
* This can be done publicly through [configs], which will also save the color
*/