package com.Tricot.calcutator.CalculatorMenu;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;

import androidx.appcompat.app.AppCompatActivity;

import com.Tricot.calcutator.R;
import com.Tricot.calcutator.data.Calculation1_pager;
import com.Tricot.calcutator.data.Calculation2_pager;

public class Bar_select extends AppCompatActivity {
    int gap=1;
    int pages;
    int menu;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bar_select);
        Button sub = (Button) findViewById(R.id.numsend);

        final RadioGroup R_group = (RadioGroup) findViewById(R.id.Bar_Group);
        Intent intent = getIntent();
        pages = intent.getExtras().getInt("pages");
        menu = intent.getExtras().getInt("menu");
        System.out.println(menu);
        sub.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(menu==1){
                    Intent intent = new Intent(getApplicationContext(), Calculation1_pager.class);
                    switch (R_group.getCheckedRadioButtonId()) {
                        case R.id.Bar_1:
                            gap = 1;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_2:
                            gap = 2;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_3:
                            gap = 3;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_4:
                            gap = 4;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_5:
                            gap = 5;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_6:
                            gap = 6;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_7:
                            gap = 7;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                    }
                }
                if(menu==2){
                    Intent intent = new Intent(getApplicationContext(), Calculation2_pager.class);
                    switch (R_group.getCheckedRadioButtonId()) {
                        case R.id.Bar_1:
                            gap = 1;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_2:
                            gap = 2;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_3:
                            gap = 3;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_4:
                            gap = 4;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_5:
                            gap = 5;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_6:
                            gap = 6;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                        case R.id.Bar_7:
                            gap = 7;
                            intent.putExtra("bars", gap);
                            intent.putExtra("pages",pages);
                            intent.putExtra("barmaker",true);
                            startActivity(intent);
                            finish();
                            break;
                    }
                }
            }
        });

    }
    public void BackClick(View v){
        finish();
    }
}
