@@ -148,7 +148,7 @@ private void onMoveGesture(float f) {
148148 */
149149 @ Override
150150 public boolean onTouchEvent (MotionEvent event ) {
151- if (!isScrollable ()) {
151+ if (!isScrollable () || isDisableTouch () ) {
152152 return super .onTouchEvent (event );
153153 }
154154
@@ -239,6 +239,7 @@ protected void onDraw(Canvas canvas) {
239239 private String [] verlabels ;
240240 private String title ;
241241 private boolean scrollable ;
242+ private boolean disableTouch ;
242243 private double viewportStart ;
243244 private double viewportSize ;
244245 private final View viewVerLabels ;
@@ -253,6 +254,7 @@ protected void onDraw(Canvas canvas) {
253254 private double manualMaxYValue ;
254255 private double manualMinYValue ;
255256 private GraphViewStyle graphViewStyle ;
257+ private GraphViewContentView graphViewContentView ;
256258
257259 public GraphView (Context context , AttributeSet attrs ) {
258260 this (context , attrs .getAttributeValue (null , "title" ));
@@ -283,7 +285,8 @@ public GraphView(Context context, String title) {
283285
284286 viewVerLabels = new VerLabelsView (context );
285287 addView (viewVerLabels );
286- addView (new GraphViewContentView (context ), new LayoutParams (LayoutParams .FILL_PARENT , LayoutParams .FILL_PARENT , 1 ));
288+ graphViewContentView = new GraphViewContentView (context );
289+ addView (graphViewContentView , new LayoutParams (LayoutParams .FILL_PARENT , LayoutParams .FILL_PARENT , 1 ));
287290 }
288291
289292 public GraphViewStyle getGraphViewStyle () {
@@ -534,6 +537,10 @@ protected double getMinY() {
534537 public boolean isScrollable () {
535538 return scrollable ;
536539 }
540+
541+ public boolean isDisableTouch () {
542+ return disableTouch ;
543+ }
537544
538545 public boolean isShowLegend () {
539546 return showLegend ;
@@ -546,6 +553,7 @@ public void redrawAll() {
546553 numberformatter [1 ] = null ;
547554 invalidate ();
548555 viewVerLabels .invalidate ();
556+ graphViewContentView .invalidate ();
549557 }
550558
551559 public void removeSeries (GraphViewSeries series )
@@ -654,6 +662,14 @@ public boolean onScale(ScaleGestureDetector detector) {
654662 public void setScrollable (boolean scrollable ) {
655663 this .scrollable = scrollable ;
656664 }
665+
666+ /**
667+ * The user can disable any touch gestures, this is useful if you are using a real time graph, but don't want the user to interact
668+ * @param disableTouch
669+ */
670+ public void setDiscableTouch (boolean disableTouch ) {
671+ this .disableTouch = disableTouch ;
672+ }
657673
658674 public void setShowLegend (boolean showLegend ) {
659675 this .showLegend = showLegend ;
0 commit comments