package barbarahliskov.cambialibros;

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


import com.google.android.gms.identity.intents.Address;

import java.util.List;

public class AddLibro extends AppCompatActivity {

    private EditText mTitulo;
    private EditText mAutor;
    private EditText mCiudad;


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

        setTitle("Añadir Libro");

        mTitulo = (EditText) findViewById(R.id.bookTituloAdd);
        mCiudad = (EditText) findViewById(R.id.bookLocationADD);
        mAutor = (EditText) findViewById(R.id.bookAutorAdd);


        Button btn = (Button) findViewById(R.id.uploadBook_button);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                attemptRegister();
                startActivity(new Intent(AddLibro.this, Libros.class));
            }
        });

       

    }



}
@@ -1282,16 +1282,904 @@
     
+ mCiudad.setOnFocusChangeListener(new View.OnFocusChangeListener() %7B%0A            @Override%0A            public void onFocusChange(View v, boolean hasFocus) %7B%0A                try %7B%0A                    Geocoder geocoder = new Geocoder(AddLibro.this);%0A                    List%3Candroid.location.Address%3E addresses;%0A%0A                        addresses = geocoder.getFromLocationName(mCiudad.getText().toString(), 1);%0A%0A                    if (addresses.size() %3E 0) %7B%0A                        double latitude = addresses.get(0).getLatitude();%0A                        double longitude = addresses.get(0).getLongitude();%0A                        ( (TextView) findViewById(R.id.coordsadd)).setText(%22Lat %22 + latitude + %22, Lon %22 + longitude);%0A                    %7D%0A                %7D catch (Exception e)%7B%0A%0A                %7D%0A            %7D%0A        %7D);%0A%0A    %7D%0A%0A    private void attemptRegister() %7B%0A        %0A%0A
 %0A%0A    %7D
-%0A
 %0A%0A%0A%7D
+%0A

version 3 añadir libros