Skip to content

Commit

Permalink
v1.7: add animation duration attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
woxingxiao committed Jan 21, 2017
1 parent 088975d commit e150126
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions bubbleseekbar/src/main/res/values/attr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
<attr name="bsb_show_section_mark" format="boolean"/>
<attr name="bsb_auto_adjust_section_mark" format="boolean"/>
<attr name="bsb_show_progress_in_float" format="boolean"/>
<attr name="bsb_anim_duration" format="integer"/>
</declare-styleable>
</resources>

0 comments on commit e150126

Please sign in to comment.