package fishrungames.kobserver;

import fishrungames.kobserver.JniWrapper;

import android.app.Activity;
import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;
import android.widget.EditText;


public class ConnectActivity extends Activity
{
	
	@Override
	protected void onCreate(Bundle icicle)
	{

		super.onCreate(icicle);

		setContentView(R.layout.connect_layout);	
		
		JniWrapper.connectActivity = this;
		
		Button connectbtn = (Button) findViewById(R.id.connectButton);
		connectbtn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                
            	
            	EditText addr_edit = (EditText) findViewById(R.id.edit_addr); 
            	EditText port_edit = (EditText) findViewById(R.id.edit_port);
            	
            	JniWrapper.Open(addr_edit.getText().toString(), port_edit.getText().toString());
            	JniWrapper.StartGetMessageTimer();
            	
            }
        });
		
		if (JniWrapper.connected)
		{
			goToMainMenu();
		}
		

	}
	
	public void goToMainMenu()
	{
		Intent myIntent = new Intent(this, MainMenuActivity.class);
        startActivityForResult(myIntent, 0);
	}
}