package in.techware.carrefour.activity;

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

import in.techware.carrefour.R;

public class PitNumberActivity extends BaseAppCompatNoDrawerActivity {

    private EditText etxtPitNumber;
    private Button btnSubmit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pit_number);

        initViews();

        if (getSupportActionBar() != null) {
            setTitle(R.string.pit_number_placeholder, R.color.white);
            getSupportActionBar().setTitle("");
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowTitleEnabled(true);
        }
    }

    private void initViews() {
        etxtPitNumber = findViewById(R.id.etxt_pit_number);

        btnSubmit = findViewById(R.id.btn_pit_number_ok);
        btnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                //mVibrator.vibrate(25);

                if(etxtPitNumber.getText().toString().length()>0){
                    Intent intent  = new Intent();
                    intent.putExtra("pitNumber",etxtPitNumber.getText().toString());
                    setResult(RESULT_OK, intent);
                    finish();
                }
            }
        });
    }
}
