summaryrefslogtreecommitdiff
path: root/client/activity-demo/Piztor/src/com/example/piztor/MainActivity.java
blob: 333bfd44c87b3309fcb6037c14fb074b92ab346a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.example.piztor;

import java.io.PrintStream;
import java.util.Vector;

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

public class MainActivity extends Activity {
	PrintStream cout = System.out;
	Button b;
	EditText username, password, ip, port;
	Login login;
	public final static String SER_KEY = "CONTROL";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		login = new Login(this);
		b = (Button) findViewById(R.id.login);
		b.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				cout.println(username.getText().toString());
				cout.println(password.getText().toString());
				cout.println(ip.getText().toString());
				cout.println(port.getText().toString());
				ip.setText("192.168.1.102");
				port.setText("9990");
				username.setText("hello");
				password.setText("world");
				 Vector<Object> r = new Vector<Object>();
				 r.add(0);
				 r.add(username.getText().toString());
				 r.add(password.getText().toString());
				 Transam t = new Transam(ip.getText().toString(), Integer
				 .parseInt(port.getText().toString()), new Myrequest(r),
				 login);
				 new Thread(t).run();
			}
		});
		username = (EditText) findViewById(R.id.username);
		password = (EditText) findViewById(R.id.password);
		ip = (EditText) findViewById(R.id.ip);
		port = (EditText) findViewById(R.id.port);
		cout.println("onCreate!");
	}

	void start() {
		Intent i = new Intent();
		i.setClass(MainActivity.this, Running.class);
		startActivity(i);
	}

	@Override
	protected void onStart() {
		super.onStart();
		cout.println("onStart!");
	}

	@Override
	protected void onRestart() {
		super.onRestart();
		cout.println("onRestart!");
	}

	@Override
	protected void onResume() {
		super.onResume();
		// cout.println("onResume!");
		// v.drawString("!!!!!");
	}

	@Override
	protected void onPause() {
		super.onPause();
		cout.println("onPause!");
	}

	@Override
	protected void onStop() {
		super.onStop();
		cout.println("onStop!");
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		cout.println("onDestroy!");
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}