From 187d8e64dc7189f63707d154166867084662dbe3 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 5 Aug 2017 23:10:28 -0700 Subject: Create debounce and update searchview (#27) * Prepare version * Create debounce base * Add debouncer and fix transition crash * Add debounce docs * Update links * Update searchview docs * Test without a ref * Add links to core components * Update links * Update to bullet points * Test core md * Test slash * Test slash * Specify implemented dependencies --- .../main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 17 ++++++----------- sample/src/main/res/xml/kau_changelog.xml | 10 +++++++--- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'sample') 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 51b8530..93fc651 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -224,18 +224,13 @@ class MainActivity : KPrefActivity() { override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) if (searchView == null) searchView = bindSearchView(menu, R.id.action_search) { - textObserver = { - observable, searchView -> - /* - * Notice that this function is automatically executed in a new thread - * and that the results will automatically be set on the ui thread - */ - observable.subscribe { - text -> - val items = wordBank.filter { it.contains(text) }.sorted().map { SearchItem(it) } - searchView.results = items - } + + textCallback = { + query, searchView -> + val items = wordBank.filter { it.contains(query) }.sorted().map { SearchItem(it) } + searchView.results = items } + textDebounceInterval = 0 noResultsFound = R.string.kau_no_results_found shouldClearOnClose = false onItemClick = { diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml index c11353d..96ae965 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -6,7 +6,13 @@ --> - + + + + + + + @@ -14,8 +20,6 @@ - - -- cgit v1.2.3