package com.view;

import java.io.IOException;

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

public class LoginWindow extends Activity {
	
	public static final int REQ_LOGIN_UPDATE=0;
	private EditText etName;
	private EditText etPassword;
	private HttpActionManager mManager = new HttpActionManager();
	
	public static void requestUpdate(Activity parent)
	{
		Intent login=new Intent(parent,LoginWindow.class);
		parent.startActivityForResult(login, REQ_LOGIN_UPDATE);
	}
	
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.login);
		
		etName=(EditText)findViewById(R.id.login_name);
		etPassword=(EditText)findViewById(R.id.login_pwd);
		
		((Button)findViewById(R.id.login_login)).setOnClickListener(click_login);
		
	}
	
	 OnClickListener click_login = new OnClickListener() {
	        public void onClick(View v) {
	        	String user_name=etName.getText().toString();
	        	String password=etPassword.getText().toString();
	        	boolean login_success=true;
/*	        	try {
					login_success=mManager.login(user_name, password);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}*/
				if(login_success==true)
				{
					Bundle b=new Bundle();
					
					setResult(RESULT_OK);finish();
					}
				
	        }
	    };

}
