From 6ad176dde0a84a0eb96dea2f9c7eb34394045526 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 24 Jun 2017 19:09:54 -0700 Subject: Push working build --- .../kotlin/ca/allanwang/kau/sample/MainActivity.kt | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'sample/src/main/kotlin') 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 7c4de5a..7680588 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -7,8 +7,13 @@ import ca.allanwang.kau.email.sendEmail import ca.allanwang.kau.kpref.CoreAttributeContract 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.bindSearchView -import ca.allanwang.kau.utils.* +import ca.allanwang.kau.utils.materialDialog +import ca.allanwang.kau.utils.navigationBarColor +import ca.allanwang.kau.utils.startActivity +import ca.allanwang.kau.utils.toast import ca.allanwang.kau.views.RippleCanvas import com.mikepenz.google_material_typeface_library.GoogleMaterial @@ -120,9 +125,18 @@ class MainActivity : KPrefActivity() { override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) - //workaround for menuY since this view draws under the status bar - val statusBarHeight = dimen(R.dimen.kau_status_bar_height).toInt().dpToPx - container.bindSearchView(menu, R.id.action_search) + container.bindSearchView(menu, R.id.action_search) { + textObserver = { + observable, searchView -> + observable.subscribe { + text -> + KL.e(text) + searchView.results = if (text.length == 3) emptyList() else Array(text.length, { text }).map { SearchItem(it) } + } + } + noResultsFound = R.string.kau_no_results_found + shouldClearOnClose = false + } return true } -- cgit v1.2.3