Skip to content

Commit

Permalink
Add a new library for resolve math expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar1123 committed Sep 20, 2016
1 parent 6494d29 commit f01810d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.jjoe64:graphview:4.1.1'
}
compile files('libs/mxparser_jdk1.7.jar')
}
Binary file added app/libs/mxparser_jdk1.7.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import org.mariuszgromada.math.mxparser.Argument;
import org.mariuszgromada.math.mxparser.Expression;

import tv.tvquetzachapin.graphfunctions.R;

Expand All @@ -21,7 +25,9 @@ protected void onCreate(Bundle savedInstanceState) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

operateEQ();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -52,4 +58,10 @@ public boolean onOptionsItemSelected(MenuItem item) {

return super.onOptionsItemSelected(item);
}

public void operateEQ() {
Argument x = new Argument("x = 5");
Expression e = new Expression("3*(x)^2",x);
Toast.makeText(MainActivity.this, "OP: " + e.calculate(), Toast.LENGTH_SHORT).show();
}
}

0 comments on commit f01810d

Please sign in to comment.