aboutsummaryrefslogtreecommitdiff
path: root/searchview/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-31 23:02:01 -0700
committerGitHub <noreply@github.com>2017-07-31 23:02:01 -0700
commit48213d0b427c478865c75fee912ff1ae8bbaffb5 (patch)
tree7aef1d8400fc3403ee5a40aba945f33a95319359 /searchview/src/main/kotlin/ca/allanwang
parent8a4e9fd44dfbcf58aa7ab63167dcbdf8752db7d0 (diff)
downloadkau-48213d0b427c478865c75fee912ff1ae8bbaffb5.tar.gz
kau-48213d0b427c478865c75fee912ff1ae8bbaffb5.tar.bz2
kau-48213d0b427c478865c75fee912ff1ae8bbaffb5.zip
Major update to core and kotterknife; create mediapicker (#15)
* Readme * Fix kau direction bits * Truly support transparent ripples * Update changelog * Test rect as base * Replace fab transition with generic fade scale transition * Add scalexy func * Add scaleXY * Add arguments to fadeScaleTransition * Clean up ink indicator * Create setOnSingleTapListener * Fix lint and add rndColor * Create kotterknife resettables * Add readme and missing object * Create lazy resettable registered * Update core docs * Opt for separate class for resettable registry * Clean up resettable registry * Rename functions * Add ripple callback listener * Adjust kprefactivity desc color * Add more transitions * Add delete keys option * Add instrumentation tests * switch id * Revert automatic instrumental tests * Generify imagepickercore and prepare video alternative * Create working video picker * Address possible null issue * Update searchview * Make layouts public * Add changelog test * Update logo link * Add custom color gif
Diffstat (limited to 'searchview/src/main/kotlin/ca/allanwang')
-rw-r--r--searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt16
1 files changed, 6 insertions, 10 deletions
diff --git a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
index 30e224e..4058f16 100644
--- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
+++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
@@ -16,7 +16,6 @@ import android.view.*
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.ProgressBar
-import ca.allanwang.kau.animators.NoAnimator
import ca.allanwang.kau.kotlin.nonReadable
import ca.allanwang.kau.searchview.SearchView.Configs
import ca.allanwang.kau.ui.views.BoundedCardView
@@ -286,7 +285,7 @@ class SearchView @JvmOverloads constructor(
fun bind(menu: Menu, @IdRes id: Int, @ColorInt menuIconColor: Int = Color.WHITE, config: Configs.() -> Unit = {}): SearchView {
config(config)
configs.textObserver(textEvents.filter { it.isNotBlank() }, this)
- menuItem = menu.findItem(id)
+ menuItem = menu.findItem(id) ?: throw IllegalArgumentException("Menu item with given id doesn't exist")
if (menuItem!!.icon == null) menuItem!!.icon = GoogleMaterial.Icon.gmd_search.toDrawable(context, 18, menuIconColor)
card.gone()
menuItem!!.setOnMenuItemClickListener { configureCoords(it); revealOpen(); true }
@@ -294,9 +293,11 @@ class SearchView @JvmOverloads constructor(
return this
}
- fun unBind(replacementMenuItemClickListener: MenuItem.OnMenuItemClickListener? = null) {
+ fun unBind(replacementMenuItemClickListener: ((item: MenuItem) -> Boolean)? = null) {
parentViewGroup.removeView(this)
- menuItem?.setOnMenuItemClickListener(replacementMenuItemClickListener)
+ if (replacementMenuItemClickListener != null)
+ menuItem?.setOnMenuItemClickListener(replacementMenuItemClickListener)
+ menuItem = null
}
fun configureCoords(item: MenuItem) {
@@ -309,11 +310,7 @@ class SearchView @JvmOverloads constructor(
card.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
view.viewTreeObserver.removeOnPreDrawListener(this)
- val topAlignment = menuY - card.height / 2
- val params = (card.layoutParams as MarginLayoutParams).apply {
- topMargin = topAlignment
- }
- card.layoutParams = params
+ card.setMarginTop(menuY - card.height / 2)
return false
}
})
@@ -376,7 +373,6 @@ class SearchView @JvmOverloads constructor(
onFinish = {
configs.closeListener?.invoke(this@SearchView)
if (configs.shouldClearOnClose) editText.text.clear()
- recycler.gone()
})
}
}