diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-26 15:43:32 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-26 15:43:32 -0700 |
commit | 600524d548105aa026c0d1900d503bab34c38ce4 (patch) | |
tree | c83ff4ba6d35321e5cd98b8effca59656114043e /sample/src/main/kotlin | |
parent | c09b59f09a24d79ff306aea7dd86e6ca2b2c3208 (diff) | |
download | kau-600524d548105aa026c0d1900d503bab34c38ce4.tar.gz kau-600524d548105aa026c0d1900d503bab34c38ce4.tar.bz2 kau-600524d548105aa026c0d1900d503bab34c38ce4.zip |
Add back press helper
Diffstat (limited to 'sample/src/main/kotlin')
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt index 51010c0..83523fa 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -9,6 +9,7 @@ import ca.allanwang.kau.kpref.KPrefActivity import ca.allanwang.kau.kpref.KPrefAdapterBuilder import ca.allanwang.kau.logging.KL import ca.allanwang.kau.searchview.SearchItem +import ca.allanwang.kau.searchview.SearchView import ca.allanwang.kau.searchview.bindSearchView import ca.allanwang.kau.utils.materialDialog import ca.allanwang.kau.utils.navigationBarColor @@ -20,6 +21,8 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial class MainActivity : KPrefActivity() { + lateinit var searchView: SearchView + override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = { textColor = { KPrefSample.textColor } accentColor = { KPrefSample.accentColor } @@ -95,6 +98,9 @@ class MainActivity : KPrefActivity() { subItems(R.string.sub_item, subPrefs()) { descRes = R.string.sub_item_desc } + + plainText(R.string.kau_lorem_ipsum) + } fun subPrefs(): KPrefAdapterBuilder.() -> Unit = { @@ -125,7 +131,7 @@ class MainActivity : KPrefActivity() { override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) - container.bindSearchView(menu, R.id.action_search) { + searchView = container.bindSearchView(menu, R.id.action_search) { textObserver = { observable, searchView -> observable.subscribe { @@ -155,4 +161,7 @@ class MainActivity : KPrefActivity() { return true } + override fun onBackPressed() { + if (!searchView.onBackPressed()) super.onBackPressed() + } } |