From 600524d548105aa026c0d1900d503bab34c38ce4 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 26 Jun 2017 15:43:32 -0700 Subject: Add back press helper --- .../src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sample/src/main/kotlin/ca') 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() + } } -- cgit v1.2.3