diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:23:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:23:13 +0000 |
commit | 300a8683b9c28424fb0f0c571a0abe128c461f69 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/dialer/app/widget/ActionBarController.java | |
parent | d67f1627521b174f12e0c247f154c7c93c5e408e (diff) | |
parent | 10b34a5ebf12e97ecba0caf3c8e30b476b038a96 (diff) |
Update Dialer to V10 RC16
am: 10b34a5ebf
Change-Id: Iea3e96ccdeaf1fa796ceca702cace82ca20f298c
Diffstat (limited to 'java/com/android/dialer/app/widget/ActionBarController.java')
-rw-r--r-- | java/com/android/dialer/app/widget/ActionBarController.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/java/com/android/dialer/app/widget/ActionBarController.java b/java/com/android/dialer/app/widget/ActionBarController.java index d0eb326ab..c1b4cc2b4 100644 --- a/java/com/android/dialer/app/widget/ActionBarController.java +++ b/java/com/android/dialer/app/widget/ActionBarController.java @@ -49,6 +49,20 @@ public class ActionBarController { } }; + private final AnimationCallback mFadeInCallback = + new AnimationCallback() { + @Override + public void onAnimationEnd() { + slideActionBar(false /* slideUp */, false /* animate */); + } + + @Override + public void onAnimationCancel() { + slideActionBar(false /* slideUp */, false /* animate */); + } + }; + private ValueAnimator mAnimator; + public ActionBarController(ActivityUi activityUi, SearchEditTextLayout searchBox) { mActivityUi = activityUi; mSearchBox = searchBox; @@ -107,7 +121,7 @@ public class ActionBarController { } slideActionBar(false /* slideUp */, true /* animate */); } else { - mSearchBox.fadeIn(); + mSearchBox.fadeIn(mFadeInCallback); } } } @@ -129,14 +143,18 @@ public class ActionBarController { public void slideActionBar(boolean slideUp, boolean animate) { LogUtil.d("ActionBarController.slidingActionBar", "up: %b, animate: %b", slideUp, animate); + if (mAnimator != null && mAnimator.isRunning()) { + mAnimator.cancel(); + mAnimator.removeAllUpdateListeners(); + } if (animate) { - ValueAnimator animator = slideUp ? ValueAnimator.ofFloat(0, 1) : ValueAnimator.ofFloat(1, 0); - animator.addUpdateListener( + mAnimator = slideUp ? ValueAnimator.ofFloat(0, 1) : ValueAnimator.ofFloat(1, 0); + mAnimator.addUpdateListener( animation -> { final float value = (float) animation.getAnimatedValue(); setHideOffset((int) (mActivityUi.getActionBarHeight() * value)); }); - animator.start(); + mAnimator.start(); } else { setHideOffset(slideUp ? mActivityUi.getActionBarHeight() : 0); } @@ -147,8 +165,7 @@ public class ActionBarController { mSearchBox.animate().alpha(alphaValue).start(); } - public void setHideOffset(int offset) { - mIsActionBarSlidUp = offset >= mActivityUi.getActionBarHeight(); + private void setHideOffset(int offset) { mActivityUi.setActionBarHideOffset(offset); } |