From 08d6365f0a389408b09111cd3950f85f812d066f Mon Sep 17 00:00:00 2001 From: Wynne Plaga Date: Thu, 16 Apr 2020 01:00:47 -0400 Subject: [PATCH] Allow for user configuration of suggesiton animation speed --- .../java/com/mancj/materialsearchbar/MaterialSearchBar.java | 4 +++- library/src/main/res/values/attrs.xml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java b/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java index a3e9521..72f00ed 100644 --- a/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java +++ b/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java @@ -82,6 +82,7 @@ public class MaterialSearchBar extends FrameLayout implements View.OnClickListen private boolean speechMode; private int maxSuggestionCount; + private int suggestionAnimationSpeed; private boolean navButtonEnabled; private boolean roundedSearchBarEnabled; private int dividerColor; @@ -136,6 +137,7 @@ private void init(AttributeSet attrs) { roundedSearchBarEnabled = array.getBoolean(R.styleable.MaterialSearchBar_mt_roundedSearchBarEnabled, false); dividerColor = array.getColor(R.styleable.MaterialSearchBar_mt_dividerColor, ContextCompat.getColor(getContext(), R.color.searchBarDividerColor)); searchBarColor = array.getColor(R.styleable.MaterialSearchBar_mt_searchBarColor, ContextCompat.getColor(getContext(), R.color.searchBarPrimaryColor)); + suggestionAnimationSpeed = array.getInteger(R.styleable.MaterialSearchBar_mt_suggestionsAnimationSpeed, 1200); //Icon Related Attributes menuIconRes = array.getResourceId(R.styleable.MaterialSearchBar_mt_menuIconDrawable, R.drawable.ic_dots_vertical_black_48dp); @@ -484,7 +486,7 @@ private void animateSuggestions(int from, int to) { findViewById(R.id.mt_divider).setVisibility(to > 0 ? View.VISIBLE : View.GONE); ValueAnimator animator = ValueAnimator.ofInt(from, to); - animator.setDuration(1200); + animator.setDuration(suggestionAnimationSpeed); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index e8edae6..6e093ba 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -9,6 +9,7 @@ + //Icons