[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #37 from Lauszus/master
Browse files Browse the repository at this point in the history
Real time graph didn't scroll when target api where above 13 and added ability to disable touch gestures
  • Loading branch information
jjoe64 committed Jun 26, 2013
2 parents 75e7464 + 232a15a commit a88a41e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# built application files
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/
lint.xml

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project
.settings
.checkstyle

#Ant
build.xml
ant.properties
local.properties
proguard.cfg
proguard-project.txt

# Intellij project files
*.iml
*.ipr
*.iws
.idea/
20 changes: 18 additions & 2 deletions src/com/jjoe64/graphview/GraphView.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void onMoveGesture(float f) {
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isScrollable()) {
if (!isScrollable() || isDisableTouch()) {
return super.onTouchEvent(event);
}

Expand Down Expand Up @@ -239,6 +239,7 @@ protected void onDraw(Canvas canvas) {
private String[] verlabels;
private String title;
private boolean scrollable;
private boolean disableTouch;
private double viewportStart;
private double viewportSize;
private final View viewVerLabels;
Expand All @@ -253,6 +254,7 @@ protected void onDraw(Canvas canvas) {
private double manualMaxYValue;
private double manualMinYValue;
private GraphViewStyle graphViewStyle;
private GraphViewContentView graphViewContentView;

public GraphView(Context context, AttributeSet attrs) {
this(context, attrs.getAttributeValue(null, "title"));
Expand Down Expand Up @@ -283,7 +285,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));
graphViewContentView = new GraphViewContentView(context);
addView(graphViewContentView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1));
}

public GraphViewStyle getGraphViewStyle() {
Expand Down Expand Up @@ -534,6 +537,10 @@ protected double getMinY() {
public boolean isScrollable() {
return scrollable;
}

public boolean isDisableTouch() {
return disableTouch;
}

public boolean isShowLegend() {
return showLegend;
Expand All @@ -546,6 +553,7 @@ public void redrawAll() {
numberformatter[1] = null;
invalidate();
viewVerLabels.invalidate();
graphViewContentView.invalidate();
}

public void removeSeries(GraphViewSeries series)
Expand Down Expand Up @@ -654,6 +662,14 @@ public boolean onScale(ScaleGestureDetector detector) {
public void setScrollable(boolean scrollable) {
this.scrollable = scrollable;
}

/**
* 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
* @param disableTouch
*/
public void setDiscableTouch(boolean disableTouch) {
this.disableTouch = disableTouch;
}

public void setShowLegend(boolean showLegend) {
this.showLegend = showLegend;
Expand Down

0 comments on commit a88a41e

Please sign in to comment.