Skip to content

Commit

Permalink
Ensure bars are not sharing same instance of path.
Browse files Browse the repository at this point in the history
  • Loading branch information
yccheok committed Jul 22, 2013
1 parent d5f12f5 commit cf17525
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions HoloGraphLibrary/src/com/echo/holographlibrary/BarGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class BarGraph extends View {

private ArrayList<Bar> points = new ArrayList<Bar>();
private Paint p = new Paint();
private Path path = new Path();
private Rect r;
private boolean showBarText = true;
private int indexSelected = -1;
Expand Down Expand Up @@ -118,12 +117,11 @@ public void onDraw(Canvas ca) {

r = new Rect();

path.reset();

int count = 0;
for (Bar p : points) {
r.set((int)((padding*2)*count + padding + barWidth*count), (int)(getHeight()-bottomPadding-(usableHeight*(p.getValue()/maxValue))), (int)((padding*2)*count + padding + barWidth*(count+1)), (int)(getHeight()-bottomPadding));

Path path = new Path();
path.addRect(new RectF(r.left-selectPadding, r.top-selectPadding, r.right+selectPadding, r.bottom+selectPadding), Path.Direction.CW);
p.setPath(path);
p.setRegion(new Region(r.left-selectPadding, r.top-selectPadding, r.right+selectPadding, r.bottom+selectPadding));
Expand Down

0 comments on commit cf17525

Please sign in to comment.