From e1501265848f601e801cd14e24d59cfaa933c82a Mon Sep 17 00:00:00 2001 From: woxingxiao <185578499@qq.com> Date: Sat, 21 Jan 2017 12:53:19 +0800 Subject: [PATCH] v1.7: add animation duration attribute --- .../src/main/java/com/xw/repo/BubbleSeekBar.java | 11 +++++++---- bubbleseekbar/src/main/res/values/attr.xml | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java index ff45ec1..0de25ae 100644 --- a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java +++ b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java @@ -97,6 +97,7 @@ public class BubbleSeekBar extends View { private float mBubbleCenterRawX; // 气泡的实时RawX private WindowManager.LayoutParams mLayoutParams; private int[] mPoint = new int[2]; + private long mAnimDuration = 200; public BubbleSeekBar(Context context) { this(context, null); @@ -144,6 +145,8 @@ public BubbleSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { isShowSectionMark = a.getBoolean(R.styleable.BubbleSeekBar_bsb_show_section_mark, false); isAutoAdjustSectionMark = a.getBoolean(R.styleable.BubbleSeekBar_bsb_auto_adjust_section_mark, false); isShowProgressInFloat = a.getBoolean(R.styleable.BubbleSeekBar_bsb_show_progress_in_float, false); + int duration = a.getInteger(R.styleable.BubbleSeekBar_bsb_anim_duration, -1); + mAnimDuration = duration < 0 ? 200 : duration; a.recycle(); if (mMin > mMax) { @@ -456,7 +459,7 @@ public boolean onTouchEvent(MotionEvent event) { if (isAutoAdjustSectionMark) { autoAdjustSection(); } else if (isThumbOnDragging) { - mBubbleView.animate().alpha(0f).setDuration(200) + mBubbleView.animate().alpha(0f).setDuration(mAnimDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -531,7 +534,7 @@ private void showBubble() { mBubbleView.setAlpha(0); mBubbleView.setVisibility(VISIBLE); - mBubbleView.animate().alpha(1f).setDuration(200) + mBubbleView.animate().alpha(1f).setDuration(mAnimDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { @@ -594,9 +597,9 @@ public void onAnimationUpdate(ValueAnimator animation) { ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mBubbleView, View.ALPHA, 0); if (onSection) { - animatorSet.setDuration(200).play(alphaAnim); + animatorSet.setDuration(mAnimDuration).play(alphaAnim); } else { - animatorSet.setDuration(200).playTogether(valueAnim, alphaAnim); + animatorSet.setDuration(mAnimDuration).playTogether(valueAnim, alphaAnim); } animatorSet.addListener(new AnimatorListenerAdapter() { @Override diff --git a/bubbleseekbar/src/main/res/values/attr.xml b/bubbleseekbar/src/main/res/values/attr.xml index de367c1..006d722 100644 --- a/bubbleseekbar/src/main/res/values/attr.xml +++ b/bubbleseekbar/src/main/res/values/attr.xml @@ -28,5 +28,6 @@ + \ No newline at end of file