package com.example.shridev1;

import android.content.Intent;
import android.database.Cursor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;

public class CreateNewRideActivity extends AppCompatActivity {

    Button addVehiclebutton;
    Button createNewRidebutton;

    EditText whereFrom, whereTo, pickup, carChoice, addSpace, carSeats, preferences, environment;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        // Ta bort titelbaren längst upp
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getSupportActionBar().hide();
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_createnewride);

        whereFrom = findViewById(R.id.editTextWhereFrom);
        whereTo = findViewById(R.id.editTextWhereTo);
        pickup = findViewById(R.id.editTextPickupPoint);
        carChoice = findViewById(R.id.carChoice);
        addSpace = findViewById(R.id.addSpace);
        carSeats = findViewById(R.id.carSeats);
        preferences = findViewById(R.id.editTextPreferences);
        environment = findViewById(R.id.editTextEnvironment);



        createNewRidebutton = (Button) findViewById(R.id.createTripButton);
        createNewRidebutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               MyDatabaseHelper myDB = new MyDatabaseHelper(CreateNewRideActivity.this);
                myDB.addTrip(whereFrom.getText().toString().trim(), whereTo.getText().toString().trim(), pickup.getText().toString().trim(),
                            carChoice.getText().toString().trim(), addSpace.getText().toString().trim(), carSeats.getText().toString().trim(),
                            preferences.getText().toString().trim(), environment.getText().toString().trim());

                Intent i = new Intent(getApplicationContext(), NewRideThankyouActivity.class);
                startActivity(i);
            }
        });

        addVehiclebutton = (Button) findViewById(R.id.addVehicleButton);
        addVehiclebutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(getApplicationContext(), RegisterVehicleActivity.class);
                startActivity(i);
                Log.d("CreateNewRideActivity", "Button clicked");
            }
        });

    }

}