From fa41b1b4c73b437ca30115b42c3114ac1fa4a752 Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Thu, 19 Apr 2012 12:09:56 -0500 Subject: [PATCH 1/7] Remove unused layout --- res/layout/main.xml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 res/layout/main.xml diff --git a/res/layout/main.xml b/res/layout/main.xml deleted file mode 100644 index 3a5f117d3..000000000 --- a/res/layout/main.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - From 828230ddaefadb81104d05dc10b6f0056a91efc6 Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Thu, 19 Apr 2012 12:10:51 -0500 Subject: [PATCH 2/7] Callbacks for when user is touching, new method to force redraw graph --- src/com/jjoe64/graphview/GraphView.java | 41 ++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/com/jjoe64/graphview/GraphView.java b/src/com/jjoe64/graphview/GraphView.java index a284faed1..2a5480b56 100644 --- a/src/com/jjoe64/graphview/GraphView.java +++ b/src/com/jjoe64/graphview/GraphView.java @@ -10,6 +10,8 @@ import android.graphics.Paint; import android.graphics.Paint.Align; import android.graphics.RectF; +import android.os.SystemClock; +import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.LinearLayout; @@ -34,7 +36,14 @@ static final private class GraphViewConfig { static final float HORIZONTAL_LABEL_HEIGHT = 80; } - private class GraphViewContentView extends View { + ArrayList mGraphInteractionListeners = new ArrayList(); + + public interface GraphInteractionListener { + public abstract void onGraphStartTouch(); + public abstract void onGraphStopTouch(); + } + + class GraphViewContentView extends View { private float lastTouchEventX; private float graphwidth; @@ -157,10 +166,20 @@ public boolean onTouchEvent(MotionEvent event) { if (!handled) { // if not scaled, scroll if ((event.getAction() & MotionEvent.ACTION_DOWN) == MotionEvent.ACTION_DOWN) { + + for (GraphInteractionListener listener : mGraphInteractionListeners) { + listener.onGraphStartTouch(); + } + handled = true; } if ((event.getAction() & MotionEvent.ACTION_UP) == MotionEvent.ACTION_UP) { lastTouchEventX = 0; + + for (GraphInteractionListener listener : mGraphInteractionListeners) { + listener.onGraphStopTouch(); + } + handled = true; } if ((event.getAction() & MotionEvent.ACTION_MOVE) == MotionEvent.ACTION_MOVE) { @@ -319,6 +338,26 @@ private GraphViewData[] _values(int idxSeries) { } } + public void graphDataChanged() { + horlabels = null; + verlabels = null; + viewVerLabels.invalidate(); + for (int i=0; i Date: Mon, 7 May 2012 12:24:26 -0500 Subject: [PATCH 3/7] Add method to clear graph series --- src/com/jjoe64/graphview/GraphView.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/jjoe64/graphview/GraphView.java b/src/com/jjoe64/graphview/GraphView.java index 2a5480b56..d91035a86 100644 --- a/src/com/jjoe64/graphview/GraphView.java +++ b/src/com/jjoe64/graphview/GraphView.java @@ -371,6 +371,10 @@ public void removeSeries(int index) graphSeries.remove(index); } + + public void removeAllSeries() { + graphSeries.clear(); + } public void removeSeries(GraphViewSeries series) { From e971e2cbb740e5ef7296de7d42307fafadea4bb5 Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Sat, 9 Jun 2012 14:43:42 -0500 Subject: [PATCH 4/7] Remove y labels --- src/com/jjoe64/graphview/GraphView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/jjoe64/graphview/GraphView.java b/src/com/jjoe64/graphview/GraphView.java index d91035a86..845ca2606 100644 --- a/src/com/jjoe64/graphview/GraphView.java +++ b/src/com/jjoe64/graphview/GraphView.java @@ -307,7 +307,7 @@ public GraphView(Context context, String title) { graphSeries = new ArrayList(); viewVerLabels = new VerLabelsView(context); - addView(viewVerLabels); + //addView(viewVerLabels); addView(new GraphViewContentView(context), new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1)); } From 6439e1aa364a1d22e5a70facfc9a31adfbcf7de2 Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Thu, 14 Jun 2012 09:42:40 -0500 Subject: [PATCH 5/7] Divide graph values by 1000 --- src/com/jjoe64/graphview/GraphView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/jjoe64/graphview/GraphView.java b/src/com/jjoe64/graphview/GraphView.java index 845ca2606..00b1bf9bc 100644 --- a/src/com/jjoe64/graphview/GraphView.java +++ b/src/com/jjoe64/graphview/GraphView.java @@ -424,6 +424,7 @@ protected void drawLegend(Canvas canvas, float height, float width) { * @return value to display */ protected String formatLabel(double value, boolean isValueX) { + value = (int) value / 1000; if (numberformatter == null) { numberformatter = NumberFormat.getNumberInstance(); double highestvalue = getMaxY(); From e2d76085c48be35fa1003df332e236f1325f4191 Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Thu, 14 Jun 2012 11:51:34 -0500 Subject: [PATCH 6/7] Fixes to prevent view pager from intercepting --- src/com/jjoe64/graphview/GraphView.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/jjoe64/graphview/GraphView.java b/src/com/jjoe64/graphview/GraphView.java index 00b1bf9bc..32e8aa166 100644 --- a/src/com/jjoe64/graphview/GraphView.java +++ b/src/com/jjoe64/graphview/GraphView.java @@ -43,7 +43,7 @@ public interface GraphInteractionListener { public abstract void onGraphStopTouch(); } - class GraphViewContentView extends View { + public class GraphViewContentView extends View { private float lastTouchEventX; private float graphwidth; @@ -190,7 +190,7 @@ public boolean onTouchEvent(MotionEvent event) { handled = true; } } - return handled; + return true; } } @@ -288,6 +288,7 @@ protected void onDraw(Canvas canvas) { private boolean manualYAxis; private double manualMaxYValue; private double manualMinYValue; + public GraphViewContentView mGraphContentView; /** * @@ -308,7 +309,8 @@ public GraphView(Context context, String title) { viewVerLabels = new VerLabelsView(context); //addView(viewVerLabels); - addView(new GraphViewContentView(context), new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1)); + mGraphContentView = new GraphViewContentView(context); + addView(mGraphContentView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1)); } private GraphViewData[] _values(int idxSeries) { From 55c8c9d5c1effbe9d050021dd1315e0436e03d1e Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Thu, 14 Jun 2012 11:56:23 -0500 Subject: [PATCH 7/7] Fixes for updating on scale --- src/com/jjoe64/graphview/GraphView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/jjoe64/graphview/GraphView.java b/src/com/jjoe64/graphview/GraphView.java index 32e8aa166..07ccaef0e 100644 --- a/src/com/jjoe64/graphview/GraphView.java +++ b/src/com/jjoe64/graphview/GraphView.java @@ -633,6 +633,7 @@ public boolean onScale(ScaleGestureDetector detector) { verlabels = null; horlabels = null; numberformatter = null; + graphDataChanged(); invalidate(); viewVerLabels.invalidate(); return true;