Commits

Daniel Nadeau  committed b1822b2

Fixed some allocation issues

  • Participants
  • Parent commits 933e792

Comments (0)

Files changed (14)

File HoloGraphLibrary/bin/classes/com/echo/holographlibrary/BarGraph.class

Binary file modified.

File HoloGraphLibrary/bin/classes/com/echo/holographlibrary/LineGraph.class

Binary file modified.

File HoloGraphLibrary/bin/classes/com/echo/holographlibrary/PieGraph.class

Binary file modified.

File HoloGraphLibrary/bin/holographlibrary.jar

Binary file modified.

File HoloGraphLibrary/bin/jarlist.cache

-# cache for current jar dependency. DO NOT EDIT.
-# format is <lastModified> <length> <SHA-1> <path>
-# Encoding is UTF-8

File HoloGraphLibrary/src/com/echo/holographlibrary/BarGraph.java

 public class BarGraph extends View {
 
 	private ArrayList<Bar> points = new ArrayList<Bar>();
-	private Paint p;
+	private Paint p = new Paint();
+	private Path path = new Path();
 	private Rect r;
 	private boolean showBarText = true;
 	private int indexSelected = -1;
 			int selectPadding = 4;
 			float bottomPadding = 40;
 			
-			if (p == null) p = new Paint();
-			
 			float usableHeight;
 			if (showBarText) {
 				this.p.setTextSize(40);
 			
 			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));

File HoloGraphLibrary/src/com/echo/holographlibrary/LineGraph.java

 public class LineGraph extends View {
 	
 	private ArrayList<Line> lines = new ArrayList<Line>();
+	Paint paint = new Paint();
 	private float minY = 0, minX = 0;
 	private float maxY = 0, maxX = 0;
 	private boolean isMaxYUserSet = false;
 		if (fullImage == null || shouldUpdate) {
 			fullImage = Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_8888);
 			Canvas canvas = new Canvas(fullImage);
-			Paint paint = new Paint();
+			
+			paint.reset();
 			Path path = new Path();
+			
 			float bottomPadding = 10, topPadding = 10;
 			float sidePadding = 10;
 			float usableHeight = getHeight() - bottomPadding - topPadding;
 						canvas.drawLine(i, getHeight()-bottomPadding, 0, getHeight()-bottomPadding-i, paint);
 					}
 					
-					paint = new Paint();
+					paint.reset();
+					
 					paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.CLEAR));
 					for (LinePoint p : line.getPoints()){
 						float yPercent = (p.getY()-minY)/(maxY - minY);
 						count++;
 					}
 					
-					Path pa = new Path();
-					pa.moveTo(0, getHeight()-bottomPadding);
-					pa.lineTo(sidePadding, getHeight()-bottomPadding);
-					pa.lineTo(sidePadding, 0);
-					pa.lineTo(0, 0);
-					pa.close();
-					canvas.drawPath(pa, paint);
+					path.reset();
+					
+					path.moveTo(0, getHeight()-bottomPadding);
+					path.lineTo(sidePadding, getHeight()-bottomPadding);
+					path.lineTo(sidePadding, 0);
+					path.lineTo(0, 0);
+					path.close();
+					canvas.drawPath(path, paint);
+					
+					path.reset();
+					
+					path.moveTo(getWidth(), getHeight()-bottomPadding);
+					path.lineTo(getWidth()-sidePadding, getHeight()-bottomPadding);
+					path.lineTo(getWidth()-sidePadding, 0);
+					path.lineTo(getWidth(), 0);
+					path.close();
 					
-					pa = new Path();
-					pa.moveTo(getWidth(), getHeight()-bottomPadding);
-					pa.lineTo(getWidth()-sidePadding, getHeight()-bottomPadding);
-					pa.lineTo(getWidth()-sidePadding, 0);
-					pa.lineTo(getWidth(), 0);
-					pa.close();
-					canvas.drawPath(pa, paint);
+					canvas.drawPath(path, paint);
 					
 				}
 				
 				lineCount++;
 			}
 			
-			paint = new Paint();
+			paint.reset();
 			
 			paint.setColor(Color.BLACK);
 			paint.setAlpha(50);

File HoloGraphLibrary/src/com/echo/holographlibrary/PieGraph.java

 public class PieGraph extends View {
 
 	private ArrayList<PieSlice> slices = new ArrayList<PieSlice>();
+	private Paint paint = new Paint();
+	private Path path = new Path();
+	
 	private int indexSelected = -1;
 	private int thickness = 50;
 	private OnSliceClickedListener listener;
 	
 	public void onDraw(Canvas canvas) {
 		canvas.drawColor(Color.TRANSPARENT);
-		Paint paint = new Paint();
+		paint.reset();
 		paint.setAntiAlias(true);
 		float midX, midY, radius, innerRadius;
-		Path p = new Path();
+		path.reset();
 		
 		float currentAngle = 270;
 		float currentSweep = 0;
 		
 		int count = 0;
 		for (PieSlice slice : slices){
-			p = new Path();
+			Path p = new Path();
 			paint.setColor(slice.getColor());
 			currentSweep = (slice.getValue()/totalValue)*(360);
 			p.arcTo(new RectF(midX-radius, midY-radius, midX+radius, midY+radius), currentAngle+padding, currentSweep - padding);
 			canvas.drawPath(p, paint);
 			
 			if (indexSelected == count && listener != null){
-				Path p2 = new Path();
+				path.reset();
 				paint.setColor(slice.getColor());
 				paint.setColor(Color.parseColor("#33B5E5"));
 				paint.setAlpha(100);
 				
 				if (slices.size() > 1) {
-					p2.arcTo(new RectF(midX-radius-(padding*2), midY-radius-(padding*2), midX+radius+(padding*2), midY+radius+(padding*2)), currentAngle, currentSweep+padding);
-					p2.arcTo(new RectF(midX-innerRadius+(padding*2), midY-innerRadius+(padding*2), midX+innerRadius-(padding*2), midY+innerRadius-(padding*2)), currentAngle + currentSweep + padding, -(currentSweep + padding));
-					p2.close();
+					path.arcTo(new RectF(midX-radius-(padding*2), midY-radius-(padding*2), midX+radius+(padding*2), midY+radius+(padding*2)), currentAngle, currentSweep+padding);
+					path.arcTo(new RectF(midX-innerRadius+(padding*2), midY-innerRadius+(padding*2), midX+innerRadius-(padding*2), midY+innerRadius-(padding*2)), currentAngle + currentSweep + padding, -(currentSweep + padding));
+					path.close();
 				} else {
-					p2.addCircle(midX, midY, radius+padding, Direction.CW);
+					path.addCircle(midX, midY, radius+padding, Direction.CW);
 				}
 				
-				canvas.drawPath(p2, paint);
+				canvas.drawPath(path, paint);
 				paint.setAlpha(255);
 			}
 			

File HoloGraphLibrarySample/bin/HoloGraphLibrarySample.apk

Binary file modified.

File HoloGraphLibrarySample/bin/classes.dex

Binary file modified.

File HoloGraphLibrarySample/bin/dexedLibs/actionbarsherlock-cc259784d1dda36811730a04cc55496f.jar

Binary file modified.

File HoloGraphLibrarySample/bin/dexedLibs/android-support-v4-428a3ef688addd37f439d1022c312f6f.jar

Binary file modified.

File HoloGraphLibrarySample/bin/dexedLibs/holographlibrary-88fbc127d18cb699e4a2fe526d837b75.jar

Binary file modified.

File HoloGraphLibrarySample/bin/resources.ap_

Binary file modified.