Skip to content

Commit

Permalink
tweaks / bugfixes for graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlythe committed Apr 20, 2014
1 parent 75979ba commit 352fdc1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Calculator/src/main/java/com/android2/calculator3/GraphModule.java
Expand Up @@ -47,6 +47,11 @@ public GraphTask(Graph graph, Logic logic) {
protected GraphView doInBackground(String... eq) {
final String[] equation = eq[0].split("=");

if(mLogic == null || mGraph == null) {
cancel(true);
return null;
}

if (equation.length != 2) {
mGraph.setData(new LinkedList<GraphView.Point>());
return mLogic.mGraphView;
Expand Down Expand Up @@ -86,6 +91,9 @@ protected GraphView doInBackground(String... eq) {
series.add(new GraphView.Point(x, y));
} catch (SyntaxException e) {}
}

mGraph.setData(series, false);
return mLogic.mGraphView;
} else if (equation[1].equals(mLogic.mY) && !equation[0].contains(mLogic.mY)) {
for (double x = minX; x <= maxX; x += (0.00125 * (maxX - minX))) {
if (graphChanged(eq[0], minX, maxX, minY, maxY)) return null;
Expand All @@ -109,6 +117,9 @@ protected GraphView doInBackground(String... eq) {
series.add(new GraphView.Point(x, y));
} catch (SyntaxException e) {}
}

mGraph.setData(series, false);
return mLogic.mGraphView;
} else {
for (double x = minX; x <= maxX; x += (0.005 * (maxX - minX))) {
List<Double> values = new ArrayList<Double>();
Expand Down

0 comments on commit 352fdc1

Please sign in to comment.