aboutsummaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-26 15:43:32 -0700
committerAllan Wang <me@allanwang.ca>2017-06-26 15:43:32 -0700
commit600524d548105aa026c0d1900d503bab34c38ce4 (patch)
treec83ff4ba6d35321e5cd98b8effca59656114043e /library/src
parentc09b59f09a24d79ff306aea7dd86e6ca2b2c3208 (diff)
downloadkau-600524d548105aa026c0d1900d503bab34c38ce4.tar.gz
kau-600524d548105aa026c0d1900d503bab34c38ce4.tar.bz2
kau-600524d548105aa026c0d1900d503bab34c38ce4.zip
Add back press helper
Diffstat (limited to 'library/src')
-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
*/