Unify storage calculations.
Due to one calculation using longs and the other using doubles, there were situations where the percentage was off-by-one between the two places. By changing both places to now use doubles to calculate percentages, the numbers should be unified. Change-Id: I4f4ed19326562e198273adc60a1593c7d1a6b6a7 Fixes: 37923610 Test: Manual
This commit is contained in:
@@ -39,7 +39,7 @@ public class DonutView extends View {
|
||||
// From manual testing, this is the longest we can go without visual errors.
|
||||
private static final int LINE_CHARACTER_LIMIT = 10;
|
||||
private float mStrokeWidth;
|
||||
private int mPercent;
|
||||
private double mPercent;
|
||||
private Paint mBackgroundCircle;
|
||||
private Paint mFilledArc;
|
||||
private TextPaint mTextPaint;
|
||||
@@ -118,7 +118,7 @@ public class DonutView extends View {
|
||||
getWidth() - mStrokeWidth,
|
||||
getHeight() - mStrokeWidth,
|
||||
TOP,
|
||||
(360 * mPercent / 100),
|
||||
(360 * (float) mPercent),
|
||||
false,
|
||||
mFilledArc);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public class DonutView extends View {
|
||||
/**
|
||||
* Set a percentage full to have the donut graph.
|
||||
*/
|
||||
public void setPercentage(int percent) {
|
||||
public void setPercentage(double percent) {
|
||||
mPercent = percent;
|
||||
mPercentString = Utils.formatPercentage(mPercent);
|
||||
mFullString = getContext().getString(R.string.storage_percent_full);
|
||||
|
Reference in New Issue
Block a user