Skip to content

Commit a88a41e

Browse files
committed
Merge pull request #37 from Lauszus/master
Real time graph didn't scroll when target api where above 13 and added ability to disable touch gestures
2 parents 75e7464 + 232a15a commit a88a41e

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# built application files
2+
*.ap_
3+
4+
# files for the dex VM
5+
*.dex
6+
7+
# Java class files
8+
*.class
9+
10+
# generated files
11+
bin/
12+
gen/
13+
lint.xml
14+
15+
# Local configuration file (sdk path, etc)
16+
local.properties
17+
18+
# Eclipse project files
19+
.classpath
20+
.project
21+
.settings
22+
.checkstyle
23+
24+
#Ant
25+
build.xml
26+
ant.properties
27+
local.properties
28+
proguard.cfg
29+
proguard-project.txt
30+
31+
# Intellij project files
32+
*.iml
33+
*.ipr
34+
*.iws
35+
.idea/

src/com/jjoe64/graphview/GraphView.java

100644100755
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)