package de.frajul.endlessroll.views;

import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.GameActivity;

/**
 * Created by Julian on 31.10.2017.
 */

public class ExitConfirmDialog extends Dialog implements View.OnClickListener {

    private GameActivity gameActivity;
    private Button yesButton;
    private Button noButton;

    public ExitConfirmDialog(GameActivity gameActivity) {
        super(gameActivity);
        this.gameActivity = gameActivity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.exit_confirm_dialog);
        TextView textView = (TextView) findViewById(R.id.exit_confirm_dialog_textview);
        textView.setTypeface(gameActivity.getTypeface());
        noButton = (Button) findViewById(R.id.exit_confirm_dialog_no_button);
        noButton.setTypeface(gameActivity.getTypeface());
        noButton.setOnClickListener(this);
        yesButton = (Button) findViewById(R.id.exit_confirm_dialog_yes_button);
        yesButton.setTypeface(gameActivity.getTypeface());
        yesButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        dismiss();
        if (v.equals(yesButton))
            gameActivity.exitGame();
    }
}
