From 0e687f12bd2653adb55ea002b39292678366c525 Mon Sep 17 00:00:00 2001 From: goblin911 Date: Sun, 25 Aug 2013 21:18:19 +0800 Subject: ... --- .../.history/79/2065267c2c0d00131249f322b63acde8 | 33 ++++++++++++ .../.history/79/90c475984b0d00131719b896d543f08c | 63 ++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde8 create mode 100644 client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c (limited to 'client/.metadata/.plugins/org.eclipse.core.resources/.history/79') diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde8 new file mode 100644 index 0000000..c78bc91 --- /dev/null +++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde8 @@ -0,0 +1,33 @@ +package com.macaroon.piztor; + +import android.os.Bundle; +import android.app.Activity; +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 (UserInfo.token != -1) + AppMgr.trigger(AppMgr.noToken); + else { + + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.init, menu); + return true; + } + +} diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c new file mode 100644 index 0000000..5be3de8 --- /dev/null +++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c @@ -0,0 +1,63 @@ +package com.macaroon.piztor; + +import java.util.*; + +import android.annotation.SuppressLint; + +@SuppressLint("UseSparseArrays") +public class ActMgr { + // event + PiztorAct act; + ActStatus nowStatus; + HashMap> mp; + + ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) { + this.act = act; + this.nowStatus = nowStatus; + mp = new HashMap>(); + for (int i = 0; i < r.length; i++) { + mp.put(r[i], new HashMap()); + } + } + + void trigger(int event) { + for (Integer i : mp.get(nowStatus).keySet()) + System.out.println(i); + 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); + } + } + + void add(ActStatus a, int event, ActStatus b) { + if (mp.containsKey(a)) { + HashMap h = mp.get(a); + h.put(event, b); + mp.put(a, h); + } else { + HashMap h = new HashMap(); + 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) { + } + +} -- cgit v1.2.3