package com.eni.android.parcelableejemplo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ParcelableEjemplo extends Activity {

	private final String EXTRA_USER = "user";

	private EditText login;
	private EditText password;
	private Button connection;

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        login = (EditText) findViewById(R.id.user);
        password = (EditText) findViewById(R.id.pass);
        connection = (Button) findViewById(R.id.connect);
        connection.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(ParcelableEjemplo.this, ConnectedActivity.class);
				User user = new User(login.getText().toString(), password.getText().toString());
				intent.putExtra(EXTRA_USER, user);
				startActivity(intent);
			}
		});
    }

}
