From a931fa42e3e938dcc1a60fec92b882aebd49a744 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 26 Jun 2017 19:55:04 -0700 Subject: Add some comments --- library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'library/src/main/kotlin') 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 a0330c5..5936a07 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt @@ -360,11 +360,11 @@ class SearchView @JvmOverloads constructor( * The cardView matches the parent's width, so menuX is correct */ configs.openListener?.invoke(this) + shadow.fadeIn() editText.showKeyboard() card.circularReveal(menuX, menuHalfHeight, duration = configs.revealDuration) { cardTransition() recycler.visible() - shadow.fadeIn() } } @@ -396,7 +396,11 @@ annotation class KauSearch fun Activity.bindSearchView(menu: Menu, @IdRes id: Int, @ColorInt menuIconColor: Int = Color.WHITE, config: SearchView.Configs.() -> Unit = {}): SearchView = findViewById(android.R.id.content).bindSearchView(menu, id, menuIconColor, config) - +/** + * Bind searchView to a menu item; call this in [Activity.onCreateOptionsMenu] + * Be wary that if you may reinflate the menu many times (eg through [Activity.invalidateOptionsMenu]), + * it may be worthwhile to hold a reference to the searchview and only bind it if it hasn't been bound before + */ @KauSearch fun ViewGroup.bindSearchView(menu: Menu, @IdRes id: Int, @ColorInt menuIconColor: Int = Color.WHITE, config: SearchView.Configs.() -> Unit = {}): SearchView { val searchView = SearchView(context) -- cgit v1.2.3