package com.example.carolina.times;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;


public class MainActivity4 extends ActionBarActivity {

    private MediaPlayer mediaPlayer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_4);

        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setIcon(R.mipmap.ic_launcher);

       // mediaPlayer = MediaPlayer.create(this, R.raw.prev);
       // mediaPlayer.start();

    }

    public void exit(View view)
    {
        moveTaskToBack(true);
        MainActivity4.this.finish();

        android.os.Process.killProcess(android.os.Process.myPid());
        System.exit(1);
    }

    public void VolverCalibrar(View view)
    {
        Intent in = new Intent(getBaseContext(), MainActivity2.class);
        startActivity(in);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main_activity4, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.autor) {
            String msn = "Nombre:\nCarolina Souto Venturini\nE-Mail:\ncarsouto@yahoo.com";
            MensajeEmergente("Autor.",msn, "OK");
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    public void MensajeEmergente(String titulo, String mensaje, String boton)
    {
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity4.this).create();
        alertDialog.setTitle(titulo);
        alertDialog.setMessage(mensaje);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, boton,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }
}
