Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
dodocat committed Dec 23, 2014
2 parents 87a0b89 + 13e383a commit a5439d0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
In build.gradle config dependency.

``` groovy
compile 'org.quanqi:CircularProgress:1.0.0'
compile 'org.quanqi:CircularProgress:1.0.2'
```

In laout xml
Expand Down
1 change: 1 addition & 0 deletions deploy.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Chris Banes
* Copyright 2014 Jing Quanqi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion library/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.0.1
VERSION_NAME=1.0.2
VERSION_CODE=2
GROUP=org.quanqi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public class CircularProgressDrawable extends Drawable implements Animatable {

private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator();

private static final int ANGLE_ANIMATOR_DURATION = 2000;
private int angleAnimatorDuration = 2000;

private static final int SWEEP_ANIMATOR_DURATION = 600;
private int sweepAnimatorDuration = 600;

private int minSweepAngle = 30;

private static final int MIN_SWEEP_ANGLE = 30;
private final RectF fBounds = new RectF();

private ObjectAnimator mObjectAnimatorSweep;
Expand Down Expand Up @@ -67,10 +68,10 @@ public void draw(Canvas canvas) {
float startAngle = mCurrentGlobalAngle - mCurrentGlobalAngleOffset;
float sweepAngle = mCurrentSweepAngle;
if (mModeAppearing) {
sweepAngle += MIN_SWEEP_ANGLE;
sweepAngle += minSweepAngle;
} else {
startAngle = startAngle + sweepAngle;
sweepAngle = 360 - sweepAngle - MIN_SWEEP_ANGLE;
sweepAngle = 360 - sweepAngle - minSweepAngle;
}
canvas.drawArc(fBounds, startAngle, sweepAngle, false, mPaint);
}
Expand All @@ -93,7 +94,7 @@ public int getOpacity() {
private void toggleAppearingMode() {
mModeAppearing = !mModeAppearing;
if (mModeAppearing) {
mCurrentGlobalAngleOffset = (mCurrentGlobalAngleOffset + MIN_SWEEP_ANGLE * 2) % 360;
mCurrentGlobalAngleOffset = (mCurrentGlobalAngleOffset + minSweepAngle * 2) % 360;
}
}

Expand Down Expand Up @@ -136,14 +137,14 @@ public void set(CircularProgressDrawable object, Float value) {
private void setupAnimations() {
mObjectAnimatorAngle = ObjectAnimator.ofFloat(this, mAngleProperty, 360f);
mObjectAnimatorAngle.setInterpolator(ANGLE_INTERPOLATOR);
mObjectAnimatorAngle.setDuration(ANGLE_ANIMATOR_DURATION);
mObjectAnimatorAngle.setDuration(angleAnimatorDuration);
mObjectAnimatorAngle.setRepeatMode(ValueAnimator.RESTART);
mObjectAnimatorAngle.setRepeatCount(ValueAnimator.INFINITE);

mObjectAnimatorSweep = ObjectAnimator.ofFloat(this,
mSweepProperty, 360f - MIN_SWEEP_ANGLE * 2);
mSweepProperty, 360f - minSweepAngle * 2);
mObjectAnimatorSweep.setInterpolator(SWEEP_INTERPOLATOR);
mObjectAnimatorSweep.setDuration(SWEEP_ANIMATOR_DURATION);
mObjectAnimatorSweep.setDuration(sweepAnimatorDuration);
mObjectAnimatorSweep.setRepeatMode(ValueAnimator.RESTART);
mObjectAnimatorSweep.setRepeatCount(ValueAnimator.INFINITE);
mObjectAnimatorSweep.addListener(new Animator.AnimatorListener() {
Expand Down Expand Up @@ -214,4 +215,37 @@ public float getCurrentSweepAngle() {
return mCurrentSweepAngle;
}

public static final class Builder {

private CircularProgressDrawable drawable;
private int angleAnimatorDuration = 2000;
private int sweepAnimatorDuration = 600;
private int minSweepAngle = 30;
private int borderWidth = 4;
private int color = 0x00ff00;

public CircularProgressDrawable build() {
CircularProgressDrawable drawable = new CircularProgressDrawable(color, borderWidth);
drawable.angleAnimatorDuration = angleAnimatorDuration;
drawable.sweepAnimatorDuration = sweepAnimatorDuration;
drawable.minSweepAngle = minSweepAngle;
return drawable;
}

public void angleAnimatorDuration(int millis) {
this.angleAnimatorDuration = millis;
}

public void sweepAnimatorDuration(int millis) {
this.sweepAnimatorDuration = millis;
}

public void borderWidth(int px) {
this.borderWidth = px;
}

public void color(int color) {
this.color = color;
}
}
}

0 comments on commit a5439d0

Please sign in to comment.