diff options
author | goblin911 <[email protected]> | 2013-08-25 21:16:45 +0800 |
---|---|---|
committer | goblin911 <[email protected]> | 2013-08-25 21:16:45 +0800 |
commit | 2efdc2f20f0306791ced5ec78a1acddfaf086f42 (patch) | |
tree | a85f2b32d6e6da9d7329ab975fea3bd79e1b94b6 /client/Piztor/src/com | |
parent | e5599da7fdd344fdcb49e8d6780a1e2ad358ee2d (diff) | |
parent | 263967cbb477983ae8680b431c1d93f102971c30 (diff) |
Merge branch 'master' of https://github.com/Determinant/piztor
Conflicts:
client/Piztor/bin/classes/com/macaroon/piztor/ActMgr.class
client/Piztor/bin/classes/com/macaroon/piztor/AppMgr.class
client/Piztor/bin/classes/com/macaroon/piztor/R$drawable.class
client/Piztor/bin/classes/com/macaroon/piztor/R$id.class
client/Piztor/bin/classes/com/macaroon/piztor/R$layout.class
client/Piztor/bin/classes/com/macaroon/piztor/R$menu.class
client/Piztor/bin/classes/com/macaroon/piztor/R$string.class
client/Piztor/gen/com/macaroon/piztor/R.java
client/Piztor/res/values/strings.xml
client/bin/classes/com/macaroon/piztor/ActStatus.class
client/bin/classes/com/macaroon/piztor/EmptyStatus.class
client/bin/classes/com/macaroon/piztor/Setting.class
client/src/com/macaroon/piztor/AppMgr.java
client/src/com/macaroon/piztor/Setting.java
Diffstat (limited to 'client/Piztor/src/com')
-rw-r--r-- | client/Piztor/src/com/macaroon/piztor/ActMgr.java | 67 | ||||
-rw-r--r-- | client/Piztor/src/com/macaroon/piztor/AppMgr.java | 89 | ||||
-rw-r--r-- | client/Piztor/src/com/macaroon/piztor/InitAct.java | 32 | ||||
-rw-r--r-- | client/Piztor/src/com/macaroon/piztor/PiztorAct.java | 60 |
4 files changed, 0 insertions, 248 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/ActMgr.java b/client/Piztor/src/com/macaroon/piztor/ActMgr.java deleted file mode 100644 index f5ff994..0000000 --- a/client/Piztor/src/com/macaroon/piztor/ActMgr.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.macaroon.piztor; - -import java.util.*; - -import android.annotation.SuppressLint; - -@SuppressLint("UseSparseArrays") -public class ActMgr { - final static int Create = -1; - // event - PiztorAct act; - ActStatus nowStatus; - HashMap<ActStatus, HashMap<Integer, ActStatus>> mp; - - ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) { - this.act = act; - this.nowStatus = nowStatus; - nowStatus.enter(Create); - mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>(); - for (int i = 0; i < r.length; i++) { - mp.put(r[i], new HashMap<Integer, ActStatus>()); - } - } - - void trigger(int event) { - System.out.println(act.id + " : " + event); - if (mp.get(nowStatus).containsKey(event)) { - nowStatus.leave(event); - nowStatus = mp.get(nowStatus).get(event); - nowStatus.enter(event); - } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) { - AppMgr.trigger(event); - } else { - System.out.println("can not trigger the event at " + act.id + " : " - + event); - } - } - - void add(ActStatus a, int event, ActStatus b) { - if (mp.containsKey(a)) { - HashMap<Integer, ActStatus> h = mp.get(a); - h.put(event, b); - mp.put(a, h); - } else { - HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>(); - h.put(event, b); - mp.put(a, h); - } - } -} - -abstract class ActStatus { - abstract void enter(int e); - - abstract void leave(int e); -} - -class EmptyStatus extends ActStatus { - @Override - void enter(int e) { - } - - @Override - void leave(int e) { - } - -} diff --git a/client/Piztor/src/com/macaroon/piztor/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java deleted file mode 100644 index 10e8e1a..0000000 --- a/client/Piztor/src/com/macaroon/piztor/AppMgr.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.macaroon.piztor; - -import java.util.HashMap; - -import android.annotation.SuppressLint; -import android.content.Intent; -import android.os.Handler; - -@SuppressLint("UseSparseArrays") -public class AppMgr { - // Status - public enum ActivityStatus{ - create, start, resume, restart, stop, pause, destroy - } - 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) { - status = st; - } - - 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); - } - - static void add(Class<?> a, Integer event, Class<?> b) { - if (mp.containsKey(a)) - mp.get(a).put(event, b); - else { - HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>(); - h.put(event, b); - mp.put(a, h); - } - } - - static void addTransition(Class<?> a, int i, Class<?> b) { - if (mp.containsKey(a)) { - HashMap<Integer, Class<?>> h = mp.get(a); - h.put(i, b); - mp.put(a, h); - } else { - HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>(); - h.put(i, b); - mp.put(a, h); - } - } - - static void addStatus(Class<?> a) { - mp.put(a, new HashMap<Integer, Class<?>>()); - } - - static void init() { - mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>(); - fromTransam = new Handler(); - transam = new Transam(Infomation.ip, Infomation.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 deleted file mode 100644 index 3986f5d..0000000 --- a/client/Piztor/src/com/macaroon/piztor/InitAct.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.macaroon.piztor; - -import android.os.Bundle; -import android.view.Menu; - -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 (Infomation.token == -1) - AppMgr.trigger(AppMgr.noToken); - else { - //TODO jump to main - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.init, menu); - return true; - } - -} diff --git a/client/Piztor/src/com/macaroon/piztor/PiztorAct.java b/client/Piztor/src/com/macaroon/piztor/PiztorAct.java deleted file mode 100644 index ad12b17..0000000 --- a/client/Piztor/src/com/macaroon/piztor/PiztorAct.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.macaroon.piztor; - -import android.app.Activity; -import android.os.Bundle; - -public class PiztorAct extends Activity { - String id; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - System.out.println(id + " on create"); - AppMgr.setStatus(AppMgr.ActivityStatus.create); - AppMgr.nowAct = this; - } - - @Override - protected void onStart() { - super.onStart(); - System.out.println(id + " on start"); - AppMgr.setStatus(AppMgr.ActivityStatus.start); - AppMgr.nowAct = this; - } - - @Override - protected void onStop() { - super.onStop(); - System.out.println(id + " on stop"); - AppMgr.setStatus(AppMgr.ActivityStatus.stop); - } - - @Override - protected void onResume() { - super.onResume(); - System.out.println(id + " on resume"); - AppMgr.setStatus(AppMgr.ActivityStatus.resume); - AppMgr.nowAct = this; - } - - @Override - protected void onPause() { - super.onPause(); - System.out.println(id + " on pause"); - AppMgr.setStatus(AppMgr.ActivityStatus.pause); - } - - @Override - protected void onRestart() { - super.onRestart(); - System.out.println(id + " on restart"); - AppMgr.setStatus(AppMgr.ActivityStatus.restart); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - System.out.println(id + " on destroy"); - AppMgr.setStatus(AppMgr.ActivityStatus.destroy); - } - -} |