Advertisement
vergepuppeter

Aemir-ResultActivity

Apr 9th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. package com.example.testexample;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4. import androidx.constraintlayout.widget.ConstraintLayout;
  5.  
  6. import android.annotation.SuppressLint;
  7. import android.content.Intent;
  8. import android.os.Bundle;
  9. import android.view.View;
  10. import android.widget.Button;
  11. import android.widget.RadioButton;
  12. import android.widget.TextView;
  13. import android.widget.Toast;
  14.  
  15. import org.w3c.dom.Text;
  16.  
  17. import javax.xml.transform.Result;
  18.  
  19. public class ResultActivity extends AppCompatActivity {
  20.  
  21. @SuppressLint("SetTextI18n")
  22. @Override
  23. protected void onCreate(Bundle savedInstanceState) {
  24. super.onCreate(savedInstanceState);
  25. setContentView(R.layout.activity_result);
  26.  
  27. ConstraintLayout conlay;
  28. TextView textView1 = (TextView) findViewById(R.id.ResultTxt);
  29. conlay = findViewById(R.id.constraintLayout);
  30.  
  31. Intent intent = getIntent();
  32. double Hinput = intent.getDoubleExtra(MainActivity.EXTRA_HINPUT, 0.0);
  33. double Winput = intent.getDoubleExtra(MainActivity.EXTRA_WINPUT, 0.0);
  34. boolean is_male = intent.getBooleanExtra(MainActivity.IS_MALE, true);
  35.  
  36. TextView gendertxt = (TextView) findViewById(R.id.TxtGender);
  37.  
  38. double result = (Winput / (Hinput * Hinput)) * 10000;
  39.  
  40. if(is_male) {
  41. if (result <= 18.5) {
  42. conlay.setBackgroundResource(R.drawable.underresult);
  43. } else if (result >= 18.6 && result <= 24.9) {
  44. conlay.setBackgroundResource(R.drawable.normalresult);
  45. } else if (result >= 25.0 && result <= 29.9) {
  46. conlay.setBackgroundResource(R.drawable.overresult);
  47. } else if (result >= 30 && result <= 39.9) {
  48. conlay.setBackgroundResource(R.drawable.obesresult);
  49. } else if (result >= 40.0) {
  50. conlay.setBackgroundResource(R.drawable.dresult);
  51. }
  52. gendertxt.setText("Male");
  53. textView1.setText(String.valueOf(result));
  54. }
  55. else{
  56. if (result <= 18.5) {
  57. conlay.setBackgroundResource(R.drawable.underresult);
  58. } else if (result >= 18.6 && result <= 24.9) {
  59. conlay.setBackgroundResource(R.drawable.normalresult);
  60. } else if (result >= 25.0 && result <= 29.9) {
  61. conlay.setBackgroundResource(R.drawable.overresult);
  62. } else if (result >= 30 && result <= 39.9) {
  63. conlay.setBackgroundResource(R.drawable.obesresult);
  64. } else if (result >= 40.0) {
  65. conlay.setBackgroundResource(R.drawable.dresult);
  66. }
  67. gendertxt.setText("Female");
  68. textView1.setText(String.valueOf(result));
  69. }
  70.  
  71. //Sharing Codes Below//
  72. Button bt;
  73. bt = (Button) findViewById(R.id.sharebtn);
  74. bt.setOnClickListener(new View.OnClickListener() {
  75. @Override
  76. public void onClick(View v) {
  77. Intent myIntent = new Intent(Intent.ACTION_SEND);
  78. myIntent.setType("text/plain");
  79. String shareBody = "Your body here";
  80. String shareSub = "Your subject here";
  81. myIntent.putExtra(Intent.EXTRA_SUBJECT, shareSub);
  82. myIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
  83. startActivity(Intent.createChooser(myIntent, "Share using"));
  84. }
  85. });
  86. //Sharing codes End here//
  87.  
  88. //Open BMI TABLE is below//
  89. Button tblbtn;
  90. tblbtn = (Button) findViewById(R.id.BmiTblBtn);
  91. tblbtn.setOnClickListener(new View.OnClickListener() {
  92. @Override
  93. public void onClick(View v) {
  94. startActivity(new Intent(ResultActivity.this, BmiTableActivity.class));
  95. }
  96. });
  97. //Open BMI TABLE Codes End here//
  98.  
  99.  
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement