Make ProgressBarDrawable implement CloneableDrawable
@@ -20,7 +20,7 @@ import android.graphics.drawable.Drawable;
/**
* Drawable that displays a progress bar based on the level.
*/
-public class ProgressBarDrawable extends Drawable {
+public class ProgressBarDrawable extends Drawable implements CloneableDrawable {
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Path mPath = new Path();
@@ -160,6 +160,20 @@ public class ProgressBarDrawable extends Drawable {
}
}
+ @Override
+ public Drawable cloneDrawable() {
+ final ProgressBarDrawable copy = new ProgressBarDrawable();
+ copy.mBackgroundColor = mBackgroundColor;
+ copy.mColor = mColor;
+ copy.mPadding = mPadding;
+ copy.mBarWidth = mBarWidth;
+ copy.mLevel = mLevel;
+ copy.mRadius = mRadius;
+ copy.mHideWhenZero = mHideWhenZero;
+ copy.mIsVertical = mIsVertical;
+ return copy;
+ }
+
private void drawHorizontalBar(Canvas canvas, int level, int color) {
Rect bounds = getBounds();
int length = (bounds.width() - 2 * mPadding) * level / 10000;
