Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ProgressBar;
Expand Down Expand Up @@ -78,4 +79,10 @@ public void progressiveStop() {
public void progressiveStop(CircularProgressDrawable.OnEndListener listener) {
checkIndeterminateDrawable().progressiveStop(listener);
}

/** Sets a matrix object to apply on the drawable */
public void setMatrix(Matrix matrix) {
CircularProgressDrawable drawable = (CircularProgressDrawable) getIndeterminateDrawable();
drawable.setMatrix(matrix);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
Expand Down Expand Up @@ -69,6 +70,9 @@ public interface OnEndListener {
private int mMaxSweepAngle;
private boolean mFirstSweepAnimation;

/** The matrix object to apply on the canvas */
private Matrix mMatrix;

private CircularProgressDrawable(int[] colors,
float borderWidth,
float sweepSpeed,
Expand Down Expand Up @@ -118,6 +122,9 @@ public void draw(Canvas canvas) {
startAngle = (startAngle + (sweepAngle - newSweepAngle)) % 360;
sweepAngle = newSweepAngle;
}
if(mMatrix != null) {
canvas.concat(mMatrix);
}
canvas.drawArc(fBounds, startAngle, sweepAngle, false, mPaint);
}

Expand Down Expand Up @@ -383,6 +390,22 @@ private void setEndRatio(float ratio) {
invalidateSelf();
}

/**
* Returns a matrix object that associated with the canvas
* @return
*/
public Matrix getMatrix() {
return mMatrix;
}

/**
* Sets a matrix object that associated with the canvas
* @param matrix
*/
public void setMatrix(Matrix matrix) {
this.mMatrix = matrix;
}

public static class Builder {
private int[] mColors;
private float mSweepSpeed;
Expand Down