Advertisement
Guest User

ResultActivity

a guest
Apr 9th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.44 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.getIntExtra(MainActivity.EXTRA_HINPUT, 0);
  33.         double Winput = intent.getIntExtra(MainActivity.EXTRA_WINPUT, 0);
  34.         TextView gendertxt = (TextView) findViewById(R.id.TxtGender);
  35.  
  36.         double calc = (Winput / (Hinput * Hinput)) * 10000;
  37.         int result = (int) calc;
  38.  
  39.         boolean is_male = intent.getBooleanExtra(MainActivity.IS_MALE, true);
  40.  
  41.         if(is_male) {
  42.             if (result <= 18.5) {
  43.                 conlay.setBackgroundResource(R.drawable.underresult);
  44.                 gendertxt.setText("Male");
  45.             } else if (result >= 18.6 && result <= 24.9) {
  46.                 conlay.setBackgroundResource(R.drawable.normalresult);
  47.                 gendertxt.setText("Male");
  48.             } else if (result >= 25.0 && result <= 29.9) {
  49.                 conlay.setBackgroundResource(R.drawable.overresult);
  50.                 gendertxt.setText("Male");
  51.             } else if (result >= 30 && result <= 39.9) {
  52.                 conlay.setBackgroundResource(R.drawable.obesresult);
  53.                 gendertxt.setText("Male");
  54.             } else if (result >= 40.0) {
  55.                 conlay.setBackgroundResource(R.drawable.dresult);
  56.                 gendertxt.setText("Male");
  57.             }
  58.             textView1.setText("" + result);
  59.             Toast.makeText(getApplicationContext(),"Male Selected",Toast.LENGTH_SHORT).show();
  60.         }
  61.         else{
  62.             if (result <= 18.5) {
  63.                 conlay.setBackgroundResource(R.drawable.underresult);
  64.                 gendertxt.setText("Female");
  65.             } else if (result >= 18.6 && result <= 24.9) {
  66.                 conlay.setBackgroundResource(R.drawable.normalresult);
  67.                 gendertxt.setText("Female");
  68.             } else if (result >= 25.0 && result <= 29.9) {
  69.                 conlay.setBackgroundResource(R.drawable.overresult);
  70.                 gendertxt.setText("Female");
  71.             } else if (result >= 30 && result <= 39.9) {
  72.                 conlay.setBackgroundResource(R.drawable.obesresult);
  73.                 gendertxt.setText("Female");
  74.             } else if (result >= 40.0) {
  75.                 conlay.setBackgroundResource(R.drawable.dresult);
  76.                 gendertxt.setText("Female");
  77.             }
  78.             textView1.setText("" + result);
  79.             Toast.makeText(getApplicationContext(),"female Selected",Toast.LENGTH_SHORT).show();
  80.         }
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.         //Sharing Codes Below//
  89.         Button bt;
  90.         bt = (Button) findViewById(R.id.sharebtn);
  91.         bt.setOnClickListener(new View.OnClickListener() {
  92.  
  93.  
  94.             @Override
  95.             public void onClick(View v) {
  96.                 Intent myIntent = new Intent(Intent.ACTION_SEND);
  97.                 myIntent.setType("text/plain");
  98.                 String shareBody = "Your body here";
  99.                 String shareSub = "Your subject here";
  100.                 myIntent.putExtra(Intent.EXTRA_SUBJECT, shareSub);
  101.                 myIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
  102.                 startActivity(Intent.createChooser(myIntent, "Share using"));
  103.  
  104.             }
  105.         });
  106.         //Sharing codes End here//
  107.  
  108.         //Open BMI TABLE is below//
  109.         Button tblbtn;
  110.         tblbtn = (Button) findViewById(R.id.BmiTblBtn);
  111.         tblbtn.setOnClickListener(new View.OnClickListener() {
  112.             @Override
  113.             public void onClick(View v) {
  114.                 startActivity(new Intent(ResultActivity.this, BmiTableActivity.class));
  115.             }
  116.         });
  117.         //Open BMI TABLE Codes End here//
  118.  
  119.  
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement