From 92539d5d901e458a06e005caa0f1666a59bcc615 Mon Sep 17 00:00:00 2001 From: Erick Chavez Date: Wed, 27 Aug 2014 21:45:46 +0200 Subject: [PATCH] possible to set custom value instead of percentage --- .../numberprogressbar/NumberProgressBar.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java b/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java index 6fa20d8..d1a0947 100644 --- a/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java +++ b/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java @@ -152,6 +152,7 @@ public class NumberProgressBar extends View { private boolean mDrawReachedBar = true; private boolean mIfDrawText = true; + private int mCustomValue; public enum ProgressTextVisibility{ Visible,Invisible @@ -287,8 +288,11 @@ private void calculateDrawRectFWithoutProgressText(){ } private void calculateDrawRectF(){ - - mCurrentDrawText = String.format("%d" ,getProgress()*100/getMax()); + if(mCustomValue == 0) + mCurrentDrawText = String.format("%d" ,getProgress()*100/getMax()); + else{ + mCurrentDrawText = String.format("%d" ,mCustomValue); + } mCurrentDrawText = mPrefix + mCurrentDrawText + mSuffix; mDrawTextWidth = mTextPaint.measureText(mCurrentDrawText); @@ -387,6 +391,10 @@ public void setReachedBarColor(int ProgressColor) { mReachedBarPaint.setColor(mReachedBarColor); invalidate(); } + public void setCustomValue(int mCustomValue) { + this.mCustomValue = mCustomValue; + invalidate(); + } public void setMax(int Max) { if(Max > 0){ @@ -488,5 +496,4 @@ public void setProgressTextVisibility(ProgressTextVisibility visibility){ } invalidate(); } - }