diff options
Diffstat (limited to 'client/Piztor/src/com')
23 files changed, 1366 insertions, 600 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/AccountSettings.java b/client/Piztor/src/com/macaroon/piztor/AccountSettings.java new file mode 100644 index 0000000..150bc64 --- /dev/null +++ b/client/Piztor/src/com/macaroon/piztor/AccountSettings.java @@ -0,0 +1,5 @@ +package com.macaroon.piztor; + +public class AccountSettings extends PiztorAct{ + +} diff --git a/client/Piztor/src/com/macaroon/piztor/ActMgr.java b/client/Piztor/src/com/macaroon/piztor/ActMgr.java index 903527e..a2ad23b 100644 --- a/client/Piztor/src/com/macaroon/piztor/ActMgr.java +++ b/client/Piztor/src/com/macaroon/piztor/ActMgr.java @@ -11,8 +11,9 @@ public class ActMgr { PiztorAct act; ActStatus nowStatus; HashMap<ActStatus, HashMap<Integer, ActStatus>> mp; - - ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) { + AppMgr appMgr; + ActMgr(AppMgr appMgr, PiztorAct act, ActStatus nowStatus, ActStatus[] r) { + this.appMgr = appMgr; this.act = act; this.nowStatus = nowStatus; nowStatus.enter(Create); @@ -29,8 +30,8 @@ public class ActMgr { 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 if (appMgr.mp.get(act.getClass()).containsKey(event)) { + appMgr.trigger(event); } else { System.out.println("can not trigger the event at " + act.id + " : " + event); diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java index d7a9d69..7e36310 100644 --- a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java +++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java @@ -13,10 +13,12 @@ import android.content.DialogInterface; import android.content.Intent; import android.location.LocationManager; import android.os.Bundle; +import android.os.CountDownTimer; import android.os.Handler; import android.os.Message; import android.provider.Settings; import android.util.Log; +import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; @@ -24,6 +26,8 @@ import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.ProgressBar; import android.widget.TextView; import android.widget.TimePicker; import android.widget.Toast; @@ -46,6 +50,8 @@ public class AlertMaker { private GeoPoint markerPoint; private MapMaker mapMaker; private long timestamp; + int mHour; + int mMinute; public AlertMaker(Context cc, MapMaker mm) { context =cc; @@ -92,33 +98,40 @@ public class AlertMaker { timestamp = System.currentTimeMillis() + tmp * 60 * 1000; return timestamp; } - + //TODO public void updateMarkerTime(int hour, int minute) { Log.d("time", hour + " " + minute); Log.d("time", " " + toTimestamp(hour, minute)); + mapMaker.newMarkerHour = hour; + mapMaker.newMarkerMinute = minute; + mapMaker.newMarkerTimestamp = toTimestamp(hour, minute); } public void showMarkerAlert(GeoPoint point) { closeBoard(context); + boolean flag = false; if (point == null) return; markerPoint = point; + calendar = Calendar.getInstance(); TimePickerDialog markerDialog = new TimePickerDialog(context , new TimePickerDialog.OnTimeSetListener() { - + boolean flag = false; @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { ////// at least 2 minutes - if ((hourOfDay >= calendar.get(Calendar.HOUR_OF_DAY) && minute >= calendar.get(Calendar.MINUTE)) - || hourOfDay > calendar.get(Calendar.HOUR_OF_DAY)) { - mapMaker.DrawMarker(markerPoint); + if ( !flag && + ((hourOfDay >= calendar.get(Calendar.HOUR_OF_DAY) && minute >= calendar.get(Calendar.MINUTE)) + || hourOfDay > calendar.get(Calendar.HOUR_OF_DAY))) { updateMarkerTime(hourOfDay, minute); - } - else { + mapMaker.DrawMarker(markerPoint); + flag = true; + Log.d("marker", "marker alert calls drawmarker"); + } else if (!flag) { Toast toast = Toast.makeText(context, - "Too early! Give me at least 2 minutes!", Toast.LENGTH_LONG); + "Too early! Give me at least 2 minutes!", Toast.LENGTH_LONG); toast.show(); closeBoard(context); showMarkerAlert(markerPoint); @@ -127,12 +140,43 @@ public class AlertMaker { } , calendar.get(Calendar.HOUR_OF_DAY) , calendar.get(Calendar.MINUTE), true); - markerDialog.show(); + markerDialog.show(); } - + public void showCheckinAlter() { closeBoard(context); - AlertDialog.Builder checkinDialog = new AlertDialog.Builder(context); + final AlertDialog.Builder checkinDialog = new AlertDialog.Builder(context); + LayoutInflater infaler = LayoutInflater.from(context); + final LinearLayout layout = (LinearLayout)infaler.inflate(R.layout.checkindialog, null); + checkinDialog.setView(layout); + checkinDialog.setNeutralButton("cancel", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + InputMethodManager im = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); + im.hideSoftInputFromWindow(layout.getWindowToken(), 0); + dialog.cancel(); + } + }); + final ProgressBar pbar = (ProgressBar)layout.findViewById(R.id.checkin_progress); + final TextView checkinInfo = (TextView)layout.findViewById(R.id.checkin_info); + checkinDialog.show(); + closeBoard(context); + new CountDownTimer(5000, 1000) { + + public void onTick(long millisUntilFinished) { + int ttt = (int)millisUntilFinished; + pbar.setProgress(ttt); + } + + public void onFinish() { + //TODO + pbar.setVisibility(View.GONE); + mapMaker.removeMarker(); + Toast toast = Toast.makeText(context, "Marker checked!", 2000); + toast.setGravity(Gravity.TOP, 0, 80); + toast.show(); + checkinInfo.setText("Success!"); + } + }.start(); } - + } diff --git a/client/Piztor/src/com/macaroon/piztor/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java index 933d2db..f1a3445 100644 --- a/client/Piztor/src/com/macaroon/piztor/AppMgr.java +++ b/client/Piztor/src/com/macaroon/piztor/AppMgr.java @@ -4,32 +4,11 @@ import java.util.HashMap; import java.util.HashSet; import android.annotation.SuppressLint; -import android.content.Context; import android.content.Intent; -import android.os.Handler; -import android.util.Log; - import com.baidu.mapapi.BMapManager; -import com.baidu.mapapi.MKGeneralListener; @SuppressLint("UseSparseArrays") public class AppMgr { - - static final String strKey = "8a0ae50048d103b2b8b12b7066f4ea7d"; - static BMapManager mBMapManager = null; - - // Status - public enum ActivityStatus { - create, start, resume, restart, stop, pause, destroy - } - - static ActivityStatus status; - static PiztorAct nowAct; - // TODO fix - static Handler handler, fromGPS; - static Transam transam = null; - static Tracker tracker = null; - static Thread tTransam, tGPS; // Event final static int noToken = 101; final static int loginSuccess = 102; @@ -37,51 +16,59 @@ public class AppMgr { final static int hasToken = 104; final static int toSettings = 105; final static int logout = 106; + final static int subscribe = 107; + final static int account = 108; + public enum ActivityStatus { + create, start, resume, restart, stop, pause, destroy + } + myApp app; + HashMap<Class<?>, HashMap<Integer, Class<?>>> mp; + HashSet<PiztorAct> acts; + ActivityStatus status; + PiztorAct nowAct; - static MapInfo mapInfo; - - static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp; - static HashSet<PiztorAct> acts; - - static void addAct(PiztorAct act) { + void addAct(PiztorAct act) { if (acts == null) acts = new HashSet<PiztorAct>(); acts.add(act); } - static void removeAct(PiztorAct act) { + void removeAct(PiztorAct act) { if (acts.contains(act)) acts.remove(act); else System.out.println("Piztor has a bug!!!!"); } - static void exit() { + void exit() { for (PiztorAct act : acts) { act.finish(); } + app.token = null; + app.mBMapManager.destroy(); } - static void setStatus(ActivityStatus st) { + void setStatus(ActivityStatus st) { status = st; } - static void trigger(int event) { + void trigger(int event) { Intent i = new Intent(); i.setClass(nowAct, mp.get(nowAct.getClass()).get(event)); if (event == errorToken) - Infomation.token = null; - if (event == loginSuccess) { - mBMapManager.start(); - mapInfo.clear(); + app.token = null; + if (event == loginSuccess || event == hasToken) { + app.mBMapManager.start(); + app.mapInfo.clear(); } if (event == logout) { - mBMapManager.stop(); + System.out.println("我来停一发!!!!"); + app.mBMapManager.stop(); } nowAct.startActivity(i); } - static void add(Class<?> a, Integer event, Class<?> b) { + void add(Class<?> a, Integer event, Class<?> b) { if (mp.containsKey(a)) mp.get(a).put(event, b); else { @@ -91,7 +78,7 @@ public class AppMgr { } } - static void addTransition(Class<?> a, int i, Class<?> b) { + void addTransition(Class<?> a, int i, Class<?> b) { if (mp.containsKey(a)) { HashMap<Integer, Class<?>> h = mp.get(a); h.put(i, b); @@ -103,38 +90,20 @@ public class AppMgr { } } - static void addStatus(Class<?> a) { + void addStatus(Class<?> a) { mp.put(a, new HashMap<Integer, Class<?>>()); } - static void init(Context context) { - if (mBMapManager == null) { - mBMapManager = new BMapManager(context); - mBMapManager.init(strKey, new MKGeneralListener() { - @Override - public void onGetNetworkState(int iError) { - Log.d("Network", "failure"); - System.out.println("network wocao ni ma de !!!!!!!!!"); - } - - @Override - public void onGetPermissionState(int iError) { - Log.d("Permission", "wrong key"); - System.out.println("ju ran bu gei wo quan xian !!!!!!!!!!"); - } - }); - } + public AppMgr(myApp app) { mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>(); - handler = new Handler(); - transam = new Transam(Infomation.ip, Infomation.port, handler); - tTransam = new Thread(transam); - tTransam.start(); - mapInfo = new MapInfo(); - Infomation.myInfo = new UserInfo(-1); + this.app = app; addStatus(InitAct.class); addStatus(Login.class); addStatus(Main.class); addStatus(Settings.class); + addTransition(Settings.class, subscribe, SubscribeSettings.class); + addTransition(SubscribeSettings.class, logout, Login.class); + addTransition(Settings.class, account, AccountSettings.class); addTransition(InitAct.class, noToken, Login.class); addTransition(InitAct.class, hasToken, Main.class); addTransition(InitAct.class, errorToken, Login.class); diff --git a/client/Piztor/src/com/macaroon/piztor/EException.java b/client/Piztor/src/com/macaroon/piztor/EException.java index 5ce1fdb..39d53c8 100644 --- a/client/Piztor/src/com/macaroon/piztor/EException.java +++ b/client/Piztor/src/com/macaroon/piztor/EException.java @@ -10,7 +10,9 @@ public class EException extends Exception { static final int EPushFailedException =104;
static final int EIOException =105;
static final int EUnknownHostException =106;
- static final int EStatusFailedException =107;
+ static final int EStatusFailedException =107;
+ static final int ELevelFailedException =108;
+ static final int EPasswordFailedException =109;
private static final long serialVersionUID = 100L;
@@ -72,4 +74,20 @@ public class EException extends Exception { public EStatusFailedException(int t,long timep) {
super(107,t,timep);
}
- }
\ No newline at end of file + }
+
+ class ELevelFailedException extends EException{
+ private static final long serialVersionUID = 108L;
+ public ELevelFailedException(int t,long timep) {
+ super(108,t,timep);
+ }
+ }
+
+ class EPasswordFailedException extends EException{
+ private static final long serialVersionUID = 109L;
+ public EPasswordFailedException(int t,long timep) {
+ super(109,t,timep);
+ }
+ }
+
+
\ No newline at end of file diff --git a/client/Piztor/src/com/macaroon/piztor/Infomation.java b/client/Piztor/src/com/macaroon/piztor/Infomation.java index 60eb03f..dbae0a0 100644 --- a/client/Piztor/src/com/macaroon/piztor/Infomation.java +++ b/client/Piztor/src/com/macaroon/piztor/Infomation.java @@ -3,13 +3,5 @@ package com.macaroon.piztor; import java.util.Vector; public class Infomation { - static String ip = "202.120.7.4"; - //static String ip = "192.168.1.171"; -// static String ip = "69.85.86.42"; -// static String ip = "192.168.1.101"; - static int port = 2223; - static String token = null; - static String username = null; - static UserInfo myInfo; - static Vector<RGroup> sublist; + } diff --git a/client/Piztor/src/com/macaroon/piztor/InitAct.java b/client/Piztor/src/com/macaroon/piztor/InitAct.java index 8145935..a4f82ff 100644 --- a/client/Piztor/src/com/macaroon/piztor/InitAct.java +++ b/client/Piztor/src/com/macaroon/piztor/InitAct.java @@ -1,16 +1,28 @@ package com.macaroon.piztor; +import com.baidu.mapapi.MKGeneralListener; + +import android.app.Activity; import android.os.Bundle; +import android.util.Log; import android.view.Menu; public class InitAct extends PiztorAct { - @Override protected void onCreate(Bundle savedInstanceState) { id = "initAct"; super.onCreate(savedInstanceState); - AppMgr.init(getApplicationContext()); - AppMgr.transam.setTimeOutTime(5000); + app.mBMapManager.init(app.getStrkey(), new MKGeneralListener() { + @Override + public void onGetNetworkState(int iError) { + Log.d("Network", "failure"); + } + + @Override + public void onGetPermissionState(int iError) { + Log.d("Permission", "wrong key"); + } + }); setContentView(R.layout.activity_init); } @@ -22,22 +34,23 @@ public class InitAct extends PiztorAct { @Override protected void onResume() { super.onResume(); - if (Infomation.token == null) - AppMgr.trigger(AppMgr.noToken); + if (app.token == null) + app.appMgr.trigger(AppMgr.noToken); else { - AppMgr.trigger(AppMgr.hasToken); + System.out.println("has token!!!"); + app.appMgr.trigger(AppMgr.hasToken); } } @Override - protected void onDestroy() { - super.onDestroy(); - } - - @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.init, menu); return false; } + + @Override + public void finishFromChild (Activity child) { + finish(); + } } diff --git a/client/Piztor/src/com/macaroon/piztor/Login.java b/client/Piztor/src/com/macaroon/piztor/Login.java index 533eeac..bdbf7ed 100644 --- a/client/Piztor/src/com/macaroon/piztor/Login.java +++ b/client/Piztor/src/com/macaroon/piztor/Login.java @@ -16,10 +16,7 @@ public class Login extends PiztorAct { Button btnLogin; EditText edtUser, edtPass; - int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3; - - @SuppressLint("HandlerLeak") Handler handler = new Handler() { @Override public void handleMessage(Message m) { @@ -32,13 +29,14 @@ public class Login extends PiztorAct { if (m.what == 0) { ResLogin res = (ResLogin) m.obj; Log.d(LogInfo.login, LogInfo.s); - Infomation.token = res.t; - Infomation.sublist = res.sublist; - Infomation.username = res.uinfo.username; - Infomation.myInfo = new UserInfo(res.uinfo.uid); - Infomation.myInfo.setInfo(res.uinfo.gid.company, + app.token = res.t; + app.sublist = res.sublist; + app.username = res.uinfo.username; + app.mapInfo.myInfo = new UserInfo(res.uinfo.uid); + app.mapInfo.myInfo.setInfo(res.uinfo.gid.company, res.uinfo.gid.section, res.uinfo.sex, res.uinfo.nickname); + app.mapInfo.myInfo.level = res.uinfo.level; System.out.println("login !!!!" + res.sublist.size()); actMgr.trigger(AppMgr.loginSuccess); } else { @@ -67,7 +65,7 @@ public class Login extends PiztorAct { String pass = edtPass.getText().toString(); long nowtime = System.currentTimeMillis(); System.out.println(user + " : " + pass + "\n"); - AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 5000)); + transam.send(new ReqLogin(user, pass, nowtime, 5000)); } @Override @@ -90,7 +88,7 @@ public class Login extends PiztorAct { ActStatus[] r = new ActStatus[2]; r[0] = new StartStatus(); r[1] = new LoginStatus(); - actMgr = new ActMgr(this, r[0], r); + actMgr = new ActMgr(appMgr, this, r[0], r); actMgr.add(r[0], loginButtonClick, r[1]); actMgr.add(r[1], loginFailed, r[0]); setContentView(R.layout.activity_login); @@ -113,16 +111,13 @@ public class Login extends PiztorAct { @Override protected void onResume() { super.onResume(); - if (AppMgr.transam == null) - Log.d(LogInfo.exception, "transam = null"); - AppMgr.transam.setHandler(handler); - + transam.setHandler(handler); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { - AppMgr.exit(); + appMgr.exit(); return true; } return super.onKeyDown(keyCode, event); diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java index 735b1a4..4efea11 100644 --- a/client/Piztor/src/com/macaroon/piztor/Main.java +++ b/client/Piztor/src/com/macaroon/piztor/Main.java @@ -1,9 +1,9 @@ package com.macaroon.piztor; +import java.lang.ref.WeakReference; import java.util.Calendar; import java.util.Vector; -import android.annotation.SuppressLint; import android.content.Context; import android.location.LocationManager; import android.os.Bundle; @@ -16,7 +16,6 @@ import android.view.Menu; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.ImageButton; -import android.widget.TextView; import android.widget.Toast; import com.baidu.location.BDLocation; @@ -26,8 +25,6 @@ import com.baidu.location.LocationClientOption; import com.baidu.mapapi.map.LocationData; import com.baidu.mapapi.map.MKMapTouchListener; import com.baidu.mapapi.map.MapView; -import com.baidu.mapapi.map.OverlayItem; -import com.baidu.mapapi.map.PopupOverlay; import com.baidu.mapapi.utils.DistanceUtil; import com.baidu.platform.comapi.basestruct.GeoPoint; @@ -41,10 +38,10 @@ public class Main extends PiztorAct { MapMaker mapMaker = null; MapView mMapView; AlertMaker alertMaker; - private Calendar calendar; GeoPoint markerPoint = null; private MKMapTouchListener mapTouchListener; private final int checkinRadius = 10; + public static int GPSrefreshrate = 5; /** * Locating component @@ -55,16 +52,22 @@ public class Main extends PiztorAct { LocationData locData = null; public MyLocationListener myListener = new MyLocationListener(); boolean isFirstLocation = true; - public static int GPSrefreshrate = 5; ImageButton btnCheckin, btnFetch, btnFocus, btnSettings; - MapInfo mapInfo; - - Transam transam; - @SuppressLint("HandlerLeak") - Handler handler = new Handler() { + + static class ReCall extends Handler { + WeakReference<Main> outerClass; + + ReCall(Main activity) { + outerClass = new WeakReference<Main>(activity); + } + @Override public void handleMessage(Message m) { + Main out = outerClass.get(); + if (out == null) { + System.out.println("act被回收了"); + } switch (m.what) { case Res.Login:// 上传自己信息成功or失败 Log.d("update location", "successfull"); @@ -74,9 +77,9 @@ public class Main extends PiztorAct { System.out.println("revieve ........" + userInfo.uinfo.size()); Vector<RUserInfo> uinfo = userInfo.uinfo; for (RUserInfo info : uinfo) { - System.out.println(info.latitude + " " - + info.longitude); - UserInfo r = mapInfo.getUserInfo(info.uid); + System.out + .println(info.latitude + " " + info.longitude); + UserInfo r = out.mapInfo.getUserInfo(info.uid); if (r != null) { r.setInfo(info.gid.company, info.gid.section, info.sex, info.nickname); @@ -86,54 +89,64 @@ public class Main extends PiztorAct { r.setInfo(info.gid.company, info.gid.section, info.sex, info.nickname); r.setLocation(info.latitude, info.longitude); - mapInfo.addUserInfo(r); + out.mapInfo.addUserInfo(r); } } - System.out.println("now has info number : " + mapInfo.allUsers.size()); - flushMap(); + System.out.println("now has info number : " + + out.mapInfo.allUsers.size()); + out.flushMap(); break; case Res.Logout:// 登出 - actMgr.trigger(AppMgr.logout); + out.actMgr.trigger(AppMgr.logout); break; case Res.PushMessage: ResPushMessage pushMessage = (ResPushMessage) m.obj; - receiveMessage(pushMessage.message); + out.receiveMessage(pushMessage.message); break; case Res.SendMessage: Log.d(LogInfo.resquest, "send message successfully"); break; case Res.PushLocation: ResPushLocation pushLocation = (ResPushLocation) m.obj; - upMapInfo(pushLocation.l); - flushMap(); + out.upMapInfo(pushLocation.l); + out.flushMap(); + break; + case Res.PushMarker: + ResPushMarker pushMarker = (ResPushMarker) m.obj; + MarkerInfo markerInfo = new MarkerInfo(); + markerInfo.level = pushMarker.level; + markerInfo.markerPoint = new GeoPoint( + (int) (pushMarker.latitude * 1e6), + (int) (pushMarker.longitude * 1e6)); + markerInfo.markerTimestamp = pushMarker.deadline; + out.mapMaker.receiveMarker(markerInfo); break; case -1: - actMgr.trigger(AppMgr.logout); + out.actMgr.trigger(AppMgr.logout); default: break; } } + } - void upMapInfo(Vector<RLocation> l) { - System.out.println("hahaha" + " " + l.size()); - for (RLocation i : l) { - UserInfo info = AppMgr.mapInfo.getUserInfo(i.id); - if (info != null) { - info.setLocation(i.latitude, i.longitude); - } else { - info = new UserInfo(i.id); - info.setLocation(i.latitude, i.longitude); - AppMgr.mapInfo.addUserInfo(info); - } + void upMapInfo(Vector<RLocation> l) { + for (RLocation i : l) { + UserInfo info = mapInfo.getUserInfo(i.id); + if (info != null) { + info.setLocation(i.latitude, i.longitude); + } else { + info = new UserInfo(i.id); + info.setLocation(i.latitude, i.longitude); + mapInfo.addUserInfo(info); } - flushMap(); } - }; + flushMap(); + } + + Handler handler = null; String cause(int t) { switch (t) { - case CheckinButtonPress: - return "Checkin Button Press"; case FocuseButtonPress: return "Focuse Button Press"; case SuccessFetch: @@ -148,14 +161,12 @@ public class Main extends PiztorAct { // TODO flush map view void flushMap() { if (mapMaker != null) - mapMaker.UpdateMap(AppMgr.mapInfo); + mapMaker.UpdateMap(mapInfo); else Log.d("exception", "!!!"); } void receiveMessage(String msg) { - System.out.println("receiveed push message!!!!!"); - System.out.println(msg); Toast toast = Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG); toast.show(); @@ -164,6 +175,7 @@ public class Main extends PiztorAct { public class MyLocationListener implements BDLocationListener { int cnt = 0; GeoPoint lastPoint = null; + @Override public void onReceiveLocation(BDLocation location) { Log.d("GPS", "Gotten"); @@ -175,15 +187,17 @@ public class Main extends PiztorAct { locData.longitude = location.getLongitude(); locData.accuracy = location.getRadius(); locData.direction = location.getDerect(); - - GeoPoint point = new GeoPoint((int)(locData.latitude * 1e6), (int)(locData.longitude * 1e6)); - if (lastPoint == null || cnt > 5 || DistanceUtil.getDistance(point, lastPoint) > 10 ) { - if (Infomation.token != null) { - Infomation.myInfo.setLocation(locData.latitude, + + GeoPoint point = new GeoPoint((int) (locData.latitude * 1e6), + (int) (locData.longitude * 1e6)); + if (lastPoint == null || cnt > 5 + || DistanceUtil.getDistance(point, lastPoint) > 10) { + if (app.token != null) { + app.mapInfo.myInfo.setLocation(locData.latitude, locData.longitude); - AppMgr.transam.send(new ReqUpdate(Infomation.token, - Infomation.username, locData.latitude, - locData.longitude, System.currentTimeMillis(), 2000)); + transam.send(new ReqUpdate(app.token, app.username, + locData.latitude, locData.longitude, System + .currentTimeMillis(), 2000)); lastPoint = point; cnt = 0; } @@ -195,22 +209,28 @@ public class Main extends PiztorAct { } int TMP = location.getLocType(); if (TMP == 61) { - Toast toast = Toast.makeText(Main.this, "Piztor : Update from GPS result (" + GPSrefreshrate + "s)", 2000); + Toast toast = Toast.makeText(Main.this, + "Piztor : Update from GPS result (" + GPSrefreshrate + + "s)", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); } if (TMP == 161) { - Toast toast = Toast.makeText(Main.this, "Piztor : Update from Network (" + GPSrefreshrate + "s)", 2000); + Toast toast = Toast.makeText(Main.this, + "Piztor : Update from Network (" + GPSrefreshrate + + "s)", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); } if (TMP == 65) { - Toast toast = Toast.makeText(Main.this, "Piztor : Update from Cache (" + GPSrefreshrate + "s)", 2000); + Toast toast = Toast.makeText(Main.this, + "Piztor : Update from Cache (" + GPSrefreshrate + "s)", + 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); } mapMaker.UpdateLocationOverlay(locData, hasAnimation); - + LocationClientOption option = new LocationClientOption(); option.setOpenGps(true); option.setCoorType("bd09ll"); @@ -232,7 +252,8 @@ public class Main extends PiztorAct { void enter(int e) { System.out.println("enter start status!!!!"); if (e == ActMgr.Create) { - System.out.println(Infomation.token + " " + Infomation.username + " " + Infomation.myInfo.uid); + System.out.println(app.token + " " + app.username + " " + + app.mapInfo.myInfo.uid); } if (e == SuccessFetch) flushMap(); @@ -246,16 +267,18 @@ public class Main extends PiztorAct { } void requestUserInfo() { - for (RGroup i : Infomation.sublist) { - ReqUserInfo r = new ReqUserInfo(Infomation.token, - Infomation.username, i, System.currentTimeMillis(), 2000); + mapInfo.clear(); + System.out.println("cleared!!!!"); + for (RGroup i : app.sublist) { + ReqUserInfo r = new ReqUserInfo(app.token, app.username, i, + System.currentTimeMillis(), 2000); transam.send(r); } System.out.println("get others infomation!!!"); } void focusOn() { - mapMaker.mMapController.animateTo(Infomation.myInfo.location); + mapMaker.mMapController.animateTo(app.mapInfo.myInfo.location); } public void InitTouchListenr() { @@ -265,7 +288,9 @@ public class Main extends PiztorAct { @Override public void onMapLongCli |