summaryrefslogtreecommitdiff
path: root/client/Piztor/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/Piztor/src')
-rw-r--r--client/Piztor/src/com/macaroon/piztor/ActMgr.java3
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AppMgr.java33
-rw-r--r--client/Piztor/src/com/macaroon/piztor/InitAct.java20
3 files changed, 47 insertions, 9 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/ActMgr.java b/client/Piztor/src/com/macaroon/piztor/ActMgr.java
index 81fa6f2..4df6bae 100644
--- a/client/Piztor/src/com/macaroon/piztor/ActMgr.java
+++ b/client/Piztor/src/com/macaroon/piztor/ActMgr.java
@@ -21,8 +21,7 @@ public class ActMgr {
}
void trigger(int event) {
- for (Integer i : mp.get(nowStatus).keySet())
- System.out.println(i);
+ System.out.println(act.id + " : " + event);
if (mp.get(nowStatus).containsKey(event)) {
nowStatus.leave(event);
nowStatus = mp.get(nowStatus).get(event);
diff --git a/client/Piztor/src/com/macaroon/piztor/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java
index 9259786..2e5e2b3 100644
--- a/client/Piztor/src/com/macaroon/piztor/AppMgr.java
+++ b/client/Piztor/src/com/macaroon/piztor/AppMgr.java
@@ -4,6 +4,7 @@ import java.util.HashMap;
import android.annotation.SuppressLint;
import android.content.Intent;
+import android.os.Handler;
@SuppressLint("UseSparseArrays")
public class AppMgr {
@@ -13,7 +14,17 @@ public class AppMgr {
}
static ActivityStatus status;
static PiztorAct nowAct;
-
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Tracker tracker = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
static void setStatus(ActivityStatus st) {
@@ -21,8 +32,12 @@ public class AppMgr {
}
static void trigger(int event) {
-
Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
nowAct.startActivity(i);
}
@@ -55,8 +70,20 @@ public class AppMgr {
static void init() {
mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tracker = new Tracker(nowAct.getApplicationContext(), fromGPS);
+ tTransam = new Thread(transam);
+ tTransam.start();
+ tGPS = new Thread(tracker);
+ tGPS.start();
+ System.out.println("!!!!!!");
addStatus(InitAct.class);
-
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
}
}
diff --git a/client/Piztor/src/com/macaroon/piztor/InitAct.java b/client/Piztor/src/com/macaroon/piztor/InitAct.java
index 1ce492c..d5a6059 100644
--- a/client/Piztor/src/com/macaroon/piztor/InitAct.java
+++ b/client/Piztor/src/com/macaroon/piztor/InitAct.java
@@ -1,20 +1,32 @@
package com.macaroon.piztor;
+import android.content.Intent;
import android.os.Bundle;
-import android.app.Activity;
+import android.os.Handler;
import android.view.Menu;
-public class InitAct extends Activity {
-
+public class InitAct extends PiztorAct {
+
@Override
protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
super.onCreate(savedInstanceState);
+ AppMgr.init();
setContentView(R.layout.activity_init);
}
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token == -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.init, menu);
return true;
}