Commit 5355c980 authored by Pyone Thant Win's avatar Pyone Thant Win
Browse files

v 0.1 debug

parent 9e2c417e
......@@ -26,7 +26,6 @@ import java.math.BigDecimal;
public class foodInfo extends AppCompatActivity {
TextView _api_result, _title;
EditText _food_name;
Button _btn_calc, _btn_start;
@Override
......@@ -34,6 +33,7 @@ public class foodInfo extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_food_info);
final String fruit = getIntent().getExtras().getString("Fruit");
//final Double sphereMass = getIntent().getExtras().getDouble("sphere mass");
final Double mass = getIntent().getExtras().getDouble("mass");
_api_result = (TextView)findViewById(R.id.api_view);
_title = (TextView)findViewById(R.id.textView_title);
......@@ -72,6 +72,7 @@ public class foodInfo extends AppCompatActivity {
JSONObject nutrients = foodNutrients.getJSONObject(3);
String amount = nutrients.getString("nutrientNumber");
Double _amount = Double.parseDouble(amount);
//Double sphereFinal = _amount/100 * sphereMass;
_amount = _amount/100 * mass;
BigDecimal bd = BigDecimal.valueOf(_amount);
bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
......
......@@ -20,6 +20,7 @@ public class top_ruler extends AppCompatActivity {
Double real_width = 0.0;
Double real_height = 0.0;
Double mass = 0.0;
//Double sphereMass = 0.0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -61,10 +62,12 @@ public class top_ruler extends AppCompatActivity {
length = findClosest(all);
}
mass = getMass(length,_real_width,_real_height, density);
//sphereMass = getSphereMass(length, real_width,_real_height, density);
//Toast.makeText(getApplicationContext(), mass.toString(), Toast.LENGTH_SHORT).show();
if (mass != 0.0){
Intent intent = new Intent(top_ruler.this, foodInfo.class);
intent.putExtra("mass", mass);
//intent.putExtra("sphere mass", sphereMass);
intent.putExtra("Fruit", fruit);
startActivity(intent);
} else{
......@@ -97,12 +100,21 @@ public class top_ruler extends AppCompatActivity {
}
return closest;
}
/*
private Double getSphereMass(Double length, Double width, Double height, Double density){
Double average = (length+width+height)/3;
Double volume = (4/3) * Math.PI * Math.pow(average/2, 3);
Double mass = volume * density;
return mass;
}
*/
private Double getMass(Double length, Double width, Double height, Double density){
Double volume, mass;
volume = length*width*height;
mass = volume * density;
return volume;
return mass;
}
private Double getValues(Integer focalLength, Double sizeInImg) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment