package barbarahliskov.cambialibros;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RatingBar;
import android.widget.TextView;

/**
 * Created by Jorge on 24/03/2017.
 */

public class Perfil extends AppCompatActivity{

    private EditText mUsuario;
    private EditText mCiudad;
    private EditText mOldPass;
    private EditText mNewPass;
    private EditText mReNewPass;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle("Mi Perfil");

        setContentView(R.layout.activity_perfil);

        mUsuario = (EditText) findViewById(R.id.user_email);
        mCiudad = (EditText) findViewById(R.id.user_city);
        mOldPass = (EditText) findViewById(R.id.oldPass);
        mNewPass = (EditText) findViewById(R.id.oldPass);
        mReNewPass = (EditText) findViewById(R.id.oldPass);

        RatingBar valmed = (RatingBar) findViewById(R.id.valoracion);
        valmed.setEnabled(false);

        Button guardar = (Button) findViewById(R.id.button_guardar);
        Button eliminar = (Button) findViewById(R.id.button_eliminar);
        Button cancelar = (Button) findViewById(R.id.button_cancelar);

        guardar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                comprobar();
            }
        });
        eliminar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                eliminarUsuario();
            }
        });
        cancelar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(Perfil.this, Menu.class);
                startActivity(i);
            }
        });



    }

    

    private boolean isEmailValid(String email) {

        return email.contains("@");
    }

    void eliminarUsuario(){
        //Eliminar usuario BBDD

        Intent i = new Intent(Perfil.this, LoginActivity.class);
        startActivity(i);
    }
}

@@ -2067,16 +2067,1050 @@
  %7D%0A%0A    
+void comprobar()%7B%0A        // Reset errors.%0A        mUsuario.setError(null);%0A        mCiudad.setError(null);%0A        mOldPass.setError(null);%0A        mNewPass.setError(null);%0A        mReNewPass.setError(null);%0A%0A        // Store values at the time of the login attempt.%0A        String email = mUsuario.getText().toString();%0A        String oldPass = mOldPass.getText().toString();%0A        String newPass = mNewPass.getText().toString();%0A        String rePass = mReNewPass.getText().toString();%0A        String ciudad = mCiudad.getText().toString();%0A%0A        boolean cancel = false;%0A        View focusView = null;%0A%0A        %0A%0A%0A        %0A        %0A%0A%0A        if (cancel) %7B%0A            // There was an error; don't attempt login and focus the first%0A            // form field with an error.%0A            focusView.requestFocus();%0A        %7D else %7B%0A            // Show a progress spinner, and kick off a background task to%0A            // perform the user login attempt.%0A            startActivity(new Intent(Perfil.this, Menu.class));%0A        %7D%0A    %7D
 %0A%0A    pr

Version 5 perfil