Merge "Fixes in UsageBarPreference"
This commit is contained in:
committed by
Android (Google) Code Review
commit
e3b5428611
@@ -27,9 +27,9 @@ import android.app.DownloadManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
|
@@ -71,20 +71,21 @@ public class PercentageBarChart extends View {
|
||||
|
||||
final int width = right - left;
|
||||
|
||||
int lastX = left;
|
||||
float lastX = left;
|
||||
|
||||
if (mEntries != null) {
|
||||
for (final Entry e : mEntries) {
|
||||
final int entryWidth;
|
||||
if (e.percentage == 0f) {
|
||||
entryWidth = 0;
|
||||
final float entryWidth;
|
||||
if (e.percentage == 0.0f) {
|
||||
entryWidth = 0.0f;
|
||||
} else {
|
||||
entryWidth = Math.max(mMinTickWidth, (int) (width * e.percentage));
|
||||
entryWidth = Math.max(mMinTickWidth, width * e.percentage);
|
||||
}
|
||||
|
||||
final int nextX = lastX + entryWidth;
|
||||
if (nextX >= right) {
|
||||
break;
|
||||
final float nextX = lastX + entryWidth;
|
||||
if (nextX > right) {
|
||||
canvas.drawRect(lastX, top, right, bottom, e.paint);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.drawRect(lastX, top, nextX, bottom, e.paint);
|
||||
@@ -92,13 +93,14 @@ public class PercentageBarChart extends View {
|
||||
}
|
||||
}
|
||||
|
||||
canvas.drawRect(lastX, top, lastX + width, bottom, mEmptyPaint);
|
||||
canvas.drawRect(lastX, top, right, bottom, mEmptyPaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background for this chart. Callers are responsible for later
|
||||
* calling {@link #invalidate()}.
|
||||
*/
|
||||
@Override
|
||||
public void setBackgroundColor(int color) {
|
||||
mEmptyPaint.setColor(color);
|
||||
}
|
||||
|
@@ -36,17 +36,17 @@ public class UsageBarPreference extends Preference {
|
||||
|
||||
public UsageBarPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
setWidgetLayoutResource(R.layout.preference_memoryusage);
|
||||
setLayoutResource(R.layout.preference_memoryusage);
|
||||
}
|
||||
|
||||
public UsageBarPreference(Context context) {
|
||||
super(context);
|
||||
setWidgetLayoutResource(R.layout.preference_memoryusage);
|
||||
setLayoutResource(R.layout.preference_memoryusage);
|
||||
}
|
||||
|
||||
public UsageBarPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setWidgetLayoutResource(R.layout.preference_memoryusage);
|
||||
setLayoutResource(R.layout.preference_memoryusage);
|
||||
}
|
||||
|
||||
public void addEntry(float percentage, int color) {
|
||||
|
Reference in New Issue
Block a user