[text] kod

Viewer

  1. package com.example.mtmp;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4. import androidx.lifecycle.ViewModelProvider;
  5.  
  6. import android.annotation.SuppressLint;
  7. import android.content.Intent;
  8. import android.os.Bundle;
  9. import android.util.Log;
  10. import android.view.View;
  11. import android.widget.Button;
  12. import android.widget.EditText;
  13. import android.widget.Switch;
  14. import android.widget.Toast;
  15.  
  16. import com.android.volley.Request;
  17. import com.android.volley.RequestQueue;
  18. import com.android.volley.Response;
  19. import com.android.volley.VolleyError;
  20. import com.android.volley.toolbox.JsonArrayRequest;
  21. import com.android.volley.toolbox.JsonObjectRequest;
  22. import com.android.volley.toolbox.Volley;
  23.  
  24. import org.json.JSONArray;
  25. import org.json.JSONException;
  26. import org.json.JSONObject;
  27.  
  28. public class MainActivity extends AppCompatActivity {
  29.     private EditText speedField, angleField;
  30.     private Switch switchInternet;
  31.  
  32.     @Override
  33.     protected void onCreate(Bundle savedInstanceState) {
  34.         super.onCreate(savedInstanceState);
  35.         setContentView(R.layout.activity_main);
  36.  
  37.         Button calculateButton = findViewById(R.id.btnVypocet);
  38.         Button animationButton = findViewById(R.id.btnUdaje);
  39.         Button graphButton = findViewById(R.id.btnUdaje2);
  40.         speedField = findViewById(R.id.speed);
  41.         angleField = findViewById(R.id.angle);
  42.         switchInternet = findViewById(R.id.switch1);
  43.  
  44.         calculateButton.setOnClickListener(view -> toCalculationActivity());
  45.         animationButton.setOnClickListener(view -> toAnimationActivity());
  46.         graphButton.setOnClickListener(view -> toGraphActivity());
  47.     }
  48.  
  49.     public void toCalculationActivity(){
  50.         if(speedField.getText().toString().isEmpty() || angleField.getText().toString().isEmpty()){
  51.             Toast.makeText(MainActivity.this, "BOTH FIELDS HAS TO BE FILLED!!!!!", Toast.LENGTH_SHORT).show();
  52.             return;
  53.         }
  54.         if(Double.parseDouble(angleField.getText().toString()) > 90){
  55.             Toast.makeText(MainActivity.this, "BETWEEN 0 AND 90 PLEASE!!!!!", Toast.LENGTH_SHORT).show();
  56.             return;
  57.         }
  58.         Intent intent = new Intent(this, CalculationActivity.class);
  59.         intent.putExtra("speed", Double.parseDouble(speedField.getText().toString()));
  60.         intent.putExtra("angle", Double.parseDouble(angleField.getText().toString()));
  61.         intent.putExtra("switch", switchInternet.isChecked());
  62.         startActivity(intent);
  63.     }
  64.  
  65.     public void toAnimationActivity(){
  66.         if(speedField.getText().toString().isEmpty() || angleField.getText().toString().isEmpty()){
  67.             Toast.makeText(MainActivity.this, "BOTH FIELDS HAS TO BE FILLED!!!!!", Toast.LENGTH_SHORT).show();
  68.             return;
  69.         }
  70.         if(Double.parseDouble(angleField.getText().toString()) > 90){
  71.             Toast.makeText(MainActivity.this, "BETWEEN 0 AND 90 PLEASE!!!!!", Toast.LENGTH_SHORT).show();
  72.             return;
  73.         }
  74.         Intent intent = new Intent(this, AnimationActivity.class);
  75.         intent.putExtra("speed", Double.parseDouble(speedField.getText().toString()));
  76.         intent.putExtra("angle", Double.parseDouble(angleField.getText().toString()));
  77.         intent.putExtra("switch", switchInternet.isChecked());
  78.         startActivity(intent);
  79.     }
  80.  
  81.     public void toGraphActivity(){
  82.         if(speedField.getText().toString().isEmpty() || angleField.getText().toString().isEmpty()){
  83.             Toast.makeText(MainActivity.this, "BOTH FIELDS HAS TO BE FILLED!!!!!", Toast.LENGTH_SHORT).show();
  84.             return;
  85.         }
  86.         if(Double.parseDouble(angleField.getText().toString()) > 90){
  87.             Toast.makeText(MainActivity.this, "BETWEEN 0 AND 90 PLEASE!!!!!", Toast.LENGTH_SHORT).show();
  88.             return;
  89.         }
  90.         Intent intent = new Intent(this, GraphActivity.class);
  91.         intent.putExtra("speed", Double.parseDouble(speedField.getText().toString()));
  92.         intent.putExtra("angle", Double.parseDouble(angleField.getText().toString()));
  93.         intent.putExtra("switch", switchInternet.isChecked());
  94.         startActivity(intent);
  95.     }
  96. }

Editor

You can edit this paste and save as new:


File Description
  • kod
  • Paste Code
  • 11 Dec-2023
  • 4.11 Kb
You can Share it: