summaryrefslogtreecommitdiff
path: root/client/Piztor/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'client/Piztor/src/com')
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AccountSettings.java5
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AlertMaker.java16
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AppMgr.java41
-rw-r--r--client/Piztor/src/com/macaroon/piztor/CopyMap.java50
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Infomation.java7
-rw-r--r--client/Piztor/src/com/macaroon/piztor/InitAct.java13
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Login.java19
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java38
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MainActivity.java133
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapMaker.java80
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Rlocation.java13
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Settings.java9
-rw-r--r--client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java119
-rw-r--r--client/Piztor/src/com/macaroon/piztor/UpdateInfo.java141
-rw-r--r--client/Piztor/src/com/macaroon/piztor/myApp.java6
15 files changed, 360 insertions, 330 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/AccountSettings.java b/client/Piztor/src/com/macaroon/piztor/AccountSettings.java
deleted file mode 100644
index 150bc64..0000000
--- a/client/Piztor/src/com/macaroon/piztor/AccountSettings.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.macaroon.piztor;
-
-public class AccountSettings extends PiztorAct{
-
-}
diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
index 7e36310..bc8e138 100644
--- a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
@@ -70,16 +70,16 @@ public class AlertMaker {
closeBoard(context);
AlertDialog.Builder gpsDialog = new AlertDialog.Builder(context);
- gpsDialog.setTitle("GPS settings");
- gpsDialog.setMessage("GPS is not enabled. Please turn it on.");
- gpsDialog.setPositiveButton("Settings",
+ gpsDialog.setTitle("GPS设置");
+ gpsDialog.setMessage("GPS未开启,是否前去打开?");
+ gpsDialog.setPositiveButton("设置",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
context.startActivity(intent);
}
});
- gpsDialog.setNegativeButton("Go without GPS",
+ gpsDialog.setNegativeButton("不使用GPS",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
@@ -131,7 +131,7 @@ public class AlertMaker {
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);
+ "太早了!多给一点时间", Toast.LENGTH_LONG);
toast.show();
closeBoard(context);
showMarkerAlert(markerPoint);
@@ -149,7 +149,7 @@ public class AlertMaker {
LayoutInflater infaler = LayoutInflater.from(context);
final LinearLayout layout = (LinearLayout)infaler.inflate(R.layout.checkindialog, null);
checkinDialog.setView(layout);
- checkinDialog.setNeutralButton("cancel", new DialogInterface.OnClickListener() {
+ checkinDialog.setNeutralButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
InputMethodManager im = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(layout.getWindowToken(), 0);
@@ -171,10 +171,10 @@ public class AlertMaker {
//TODO
pbar.setVisibility(View.GONE);
mapMaker.removeMarker();
- Toast toast = Toast.makeText(context, "Marker checked!", 2000);
+ Toast toast = Toast.makeText(context, "已签到!", 2000);
toast.setGravity(Gravity.TOP, 0, 80);
toast.show();
- checkinInfo.setText("Success!");
+ checkinInfo.setText("成功!");
}
}.start();
}
diff --git a/client/Piztor/src/com/macaroon/piztor/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java
index f1a3445..a7f1af0 100644
--- a/client/Piztor/src/com/macaroon/piztor/AppMgr.java
+++ b/client/Piztor/src/com/macaroon/piztor/AppMgr.java
@@ -1,11 +1,10 @@
package com.macaroon.piztor;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.Stack;
import android.annotation.SuppressLint;
import android.content.Intent;
-import com.baidu.mapapi.BMapManager;
@SuppressLint("UseSparseArrays")
public class AppMgr {
@@ -18,31 +17,33 @@ public class AppMgr {
final static int logout = 106;
final static int subscribe = 107;
final static int account = 108;
+ final static int finish = 109;
+
public enum ActivityStatus {
create, start, resume, restart, stop, pause, destroy
}
+
myApp app;
HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
- HashSet<PiztorAct> acts;
+ Stack<PiztorAct> acts;
ActivityStatus status;
PiztorAct nowAct;
void addAct(PiztorAct act) {
if (acts == null)
- acts = new HashSet<PiztorAct>();
- acts.add(act);
+ acts = new Stack<PiztorAct>();
+ acts.push(act);
}
- void removeAct(PiztorAct act) {
- if (acts.contains(act))
- acts.remove(act);
- else
- System.out.println("Piztor has a bug!!!!");
- }
+ /*
+ * void removeAct(PiztorAct act) { if (acts.contains(act)) acts.remove(act);
+ * else System.out.println("Piztor has a bug!!!!"); }
+ */
void exit() {
- for (PiztorAct act : acts) {
- act.finish();
+ while (!acts.isEmpty()) {
+ acts.peek().finish();
+ acts.pop();
}
app.token = null;
app.mBMapManager.destroy();
@@ -53,8 +54,10 @@ public class AppMgr {
}
void trigger(int event) {
- Intent i = new Intent();
- i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ if (event == finish) {
+ nowAct.finish();
+ return;
+ }
if (event == errorToken)
app.token = null;
if (event == loginSuccess || event == hasToken) {
@@ -63,8 +66,13 @@ public class AppMgr {
}
if (event == logout) {
System.out.println("我来停一发!!!!");
+ app.isLogout = true;
app.mBMapManager.stop();
+ nowAct.finish();
+ return;
}
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
nowAct.startActivity(i);
}
@@ -101,9 +109,10 @@ public class AppMgr {
addStatus(Login.class);
addStatus(Main.class);
addStatus(Settings.class);
+ addTransition(UpdateInfo.class, logout, Login.class);
addTransition(Settings.class, subscribe, SubscribeSettings.class);
addTransition(SubscribeSettings.class, logout, Login.class);
- addTransition(Settings.class, account, AccountSettings.class);
+ addTransition(Settings.class, account, UpdateInfo.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/CopyMap.java b/client/Piztor/src/com/macaroon/piztor/CopyMap.java
deleted file mode 100644
index 6d49767..0000000
--- a/client/Piztor/src/com/macaroon/piztor/CopyMap.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.macaroon.piztor;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import android.content.Context;
-
-public class CopyMap {
- /**
- *
- * @param myContext
- * @param ASSETS_NAME 要复制的文件名
- * @param savePath 要保存的路径
- * @param saveName 复制后的文件名
- * testCopy(Context context)是一个测试例子。
- */
-
- public static void copy(Context myContext, String ASSETS_NAME,
- String savePath, String saveName) {
- String filename = savePath + "/" + saveName;
-
- File dir = new File(savePath);
- // 如果目录不中存在,创建这个目录
- if (!dir.exists())
- dir.mkdir();
- try {
- if (!(new File(filename)).exists()) {
- InputStream is = myContext.getResources().getAssets()
- .open(ASSETS_NAME);
- System.out.println(ASSETS_NAME);
- FileOutputStream fos = new FileOutputStream(filename);
- byte[] buffer = new byte[7168];
- int count = 0;
- while ((count = is.read(buffer)) > 0) {
- fos.write(buffer, 0, count);
- }
- fos.close();
- is.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public void testCopy(Context context) {
- String path=context.getFilesDir().getAbsolutePath();
- String name="test";
- CopyMap.copy(context, name, path, name);
- }
-}
-
diff --git a/client/Piztor/src/com/macaroon/piztor/Infomation.java b/client/Piztor/src/com/macaroon/piztor/Infomation.java
deleted file mode 100644
index dbae0a0..0000000
--- a/client/Piztor/src/com/macaroon/piztor/Infomation.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.macaroon.piztor;
-
-import java.util.Vector;
-
-public class Infomation {
-
-}
diff --git a/client/Piztor/src/com/macaroon/piztor/InitAct.java b/client/Piztor/src/com/macaroon/piztor/InitAct.java
index a4f82ff..5f7f61d 100644
--- a/client/Piztor/src/com/macaroon/piztor/InitAct.java
+++ b/client/Piztor/src/com/macaroon/piztor/InitAct.java
@@ -1,17 +1,19 @@
package com.macaroon.piztor;
-import com.baidu.mapapi.MKGeneralListener;
-
import android.app.Activity;
+import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
+import com.baidu.mapapi.MKGeneralListener;
+
public class InitAct extends PiztorAct {
@Override
protected void onCreate(Bundle savedInstanceState) {
id = "initAct";
super.onCreate(savedInstanceState);
+ app.isExiting = false;
app.mBMapManager.init(app.getStrkey(), new MKGeneralListener() {
@Override
public void onGetNetworkState(int iError) {
@@ -33,12 +35,15 @@ public class InitAct extends PiztorAct {
@Override
protected void onResume() {
+ if (app.isExiting)
+ finish();
super.onResume();
- if (app.token == null)
+ if (app.token == null || app.isLogout) {
app.appMgr.trigger(AppMgr.noToken);
+ }
else {
- System.out.println("has token!!!");
app.appMgr.trigger(AppMgr.hasToken);
+ System.out.println("has token!!!");
}
}
diff --git a/client/Piztor/src/com/macaroon/piztor/Login.java b/client/Piztor/src/com/macaroon/piztor/Login.java
index bdbf7ed..3b9cbc2 100644
--- a/client/Piztor/src/com/macaroon/piztor/Login.java
+++ b/client/Piztor/src/com/macaroon/piztor/Login.java
@@ -37,6 +37,7 @@ public class Login extends PiztorAct {
res.uinfo.gid.section, res.uinfo.sex,
res.uinfo.nickname);
app.mapInfo.myInfo.level = res.uinfo.level;
+ app.mapInfo.myInfo.nickname = res.uinfo.nickname;
System.out.println("login !!!!" + res.sublist.size());
actMgr.trigger(AppMgr.loginSuccess);
} else {
@@ -85,12 +86,6 @@ public class Login extends PiztorAct {
protected void onCreate(Bundle savedInstanceState) {
id = "login";
super.onCreate(savedInstanceState);
- ActStatus[] r = new ActStatus[2];
- r[0] = new StartStatus();
- r[1] = new LoginStatus();
- 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);
}
@@ -110,15 +105,23 @@ public class Login extends PiztorAct {
@Override
protected void onResume() {
+ if (app.isExiting)
+ finish();
+ app.isLogout = false;
super.onResume();
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(appMgr, this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
transam.setHandler(handler);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
- appMgr.exit();
- return true;
+ app.isExiting = 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 4efea11..7ac1b21 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -41,7 +41,6 @@ public class Main extends PiztorAct {
GeoPoint markerPoint = null;
private MKMapTouchListener mapTouchListener;
private final int checkinRadius = 10;
- public static int GPSrefreshrate = 5;
/**
* Locating component
@@ -52,6 +51,7 @@ 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;
@@ -210,21 +210,21 @@ public class Main extends PiztorAct {
int TMP = location.getLocType();
if (TMP == 61) {
Toast toast = Toast.makeText(Main.this,
- "Piztor : Update from GPS result (" + GPSrefreshrate
+ "Piztor : 由GPS更新 (刷新时间" + 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
+ "Piztor : 由网络更新 (刷新时间" + 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)",
+ "Piztor : 由缓存更新 (刷新时间" + GPSrefreshrate + "s)",
2000);
toast.setGravity(Gravity.TOP, 0, 80);
toast.show();
@@ -311,7 +311,7 @@ public class Main extends PiztorAct {
public void markerCheckin() {
Log.d("checkin", "ok!!!");
if (mapMaker.getMakerLocation() == null) {
- Toast toast = Toast.makeText(Main.this, "No marker now!", 2000);
+ Toast toast = Toast.makeText(Main.this, "暂无路标", 2000);
toast.setGravity(Gravity.TOP, 0, 80);
toast.show();
return;
@@ -325,7 +325,7 @@ public class Main extends PiztorAct {
alertMaker.showCheckinAlter();
} else {
Toast toast = Toast.makeText(Main.this,
- "Please get closer to the marker!", 2000);
+ "请靠近路标", 2000);
toast.setGravity(Gravity.TOP, 0, 80);
toast.show();
}
@@ -340,11 +340,6 @@ public class Main extends PiztorAct {
.getSystemService(LOCATION_SERVICE);
isGPSEnabled = locationManager
.isProviderEnabled(locationManager.GPS_PROVIDER);
- ActStatus[] r = new ActStatus[1];
- ActStatus startStatus = r[0] = new StartStatus();
- transam = app.transam;
-
- actMgr = new ActMgr(appMgr, this, startStatus, r);
setContentView(R.layout.activity_main);
app.mBMapManager.start();
@@ -415,11 +410,19 @@ public class Main extends PiztorAct {
@Override
protected void onResume() {
+ if (app.isExiting || app.isLogout)
+ finish();
+ ActStatus[] r = new ActStatus[1];
+ ActStatus startStatus = r[0] = new StartStatus();
+ actMgr = new ActMgr(appMgr, this, startStatus, r);
mMapView.onResume();
transam.setHandler(handler);
isFirstLocation = true;
mLocClient.start();
- requestUserInfo();
+ if (app.token == null) {
+ System.out.println("fuck!!");
+ } else
+ requestUserInfo();
// mapMaker.onResume();
flushMap();
super.onResume();
@@ -446,7 +449,9 @@ public class Main extends PiztorAct {
if (mLocClient != null) {
mLocClient.stop();
}
- // mMapView.destroy();
+ // mapMaker.mOffline.destroy();
+ mMapView.destroy();
+ app.mBMapManager.stop();
// while null?
// mMapView.destroy();
//
@@ -457,9 +462,8 @@ public class Main extends PiztorAct {
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
System.out.println("ready to exit!!!");
- app.mBMapManager.stop();
- appMgr.exit();
- return true;
+ //
+ app.isExiting = true;
}
return super.onKeyDown(keyCode, event);
}
@@ -467,7 +471,7 @@ public class Main extends PiztorAct {
@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);
+ // getMenuInflater().inflate(R.menu.main, menu);
return false;
}
diff --git a/client/Piztor/src/com/macaroon/piztor/MainActivity.java b/client/Piztor/src/com/macaroon/piztor/MainActivity.java
deleted file mode 100644
index 483112d..0000000
--- a/client/Piztor/src/com/macaroon/piztor/MainActivity.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.macaroon.piztor;
-
-import java.util.Vector;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.view.Menu;
-import android.view.View;
-
-public class MainActivity extends Activity {
- public String token = "";
- public String uname = "";
- public int com;
- public int sec;
- public int step = 0;
- Transam t;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- t = new Transam("192.168.1.171",2223,handler);
- Thread thread = new Thread(t);
- thread.start();
-
- }
-
- Handler handler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 0:
- token = ((ResLogin) msg.obj ).t;
- uname = ((ResLogin) msg.obj ).uinfo.username;
- com = ((ResLogin) msg.obj ).uinfo.gid.company;
- sec = ((ResLogin) msg.obj ).uinfo.gid.section;
- System.out.println(com);
- System.out.println(sec);
- System.out.println(((ResLogin) msg.obj ).uinfo.sex);
- for(int i=0;i<((ResLogin) msg.obj ).subscribeNumber;i++){
- System.out.println(((ResLogin) msg.obj ).sublist.get(i).company);
- System.out.println(((ResLogin) msg.obj ).sublist.get(i).section);
- }
- System.out.println(token);
- break;
- case 2:
- ResUserInfo r = (ResUserInfo) msg.obj ;
- System.out.println(r.number);
- for(int i=0;i<r.number;i++){
- System.out.println(r.uinfo.get(i).nickname);
- System.out.println(r.uinfo.get(i).latitude);
- System.out.println(r.uinfo.get(i).longitude);
- }
- break;
- case 100:
- System.out.println(((ResPushMessage) msg.obj).message);
- break;
- case 101:
- int nn = ((ResPushLocation)msg.obj).n;
- Vector<RLocation> ll = ((ResPushLocation)msg.obj).l;
- for(int i=0;i<nn;i++){
- System.out.println(ll.get(i).latitude + " " + ll.get(i).longitude);
- }
- break;
- case -1:
- System.out.println(-1);
- }
- super.handleMessage(msg);
- }
- };
-
-
-
- @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;
- }
-
-
-
-
-
- public void sendMessage(View view) {
-
- if(step == 0){
- long time = System.currentTimeMillis();
- ReqLogin r = new ReqLogin("hello","world",time,2000);
- t.send(r);
- step++;
- }
- else if(step == 1){
- long time = System.currentTimeMillis();
- ReqUpdate r = new ReqUpdate (token,uname,123.456,654.321,time,2000);
- t.send(r);
- step++;
- }
- else if(step == 2){
- long time = System.currentTimeMillis();
- ReqSendMessage r = new ReqSendMessage (token,uname,"wurusai",time,2000);
- t.send(r);
- step++;
- }
- else if(step == 3){
- long time = System.currentTimeMillis();
- ReqLogout r = new ReqLogout(token,uname,time,2000);
- t.send(r);
- step++;
- }
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-}
-
-
-
-
-
-
diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
index 3268a57..d3699c3 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
@@ -30,7 +30,7 @@ import com.baidu.mapapi.map.PopupClickListener;
import com.baidu.mapapi.map.PopupOverlay;
import com.baidu.platform.comapi.basestruct.GeoPoint;
-public class MapMaker extends Activity {
+public class MapMaker {
// MapView controlling component
private MapView mMapView = null;
@@ -138,7 +138,7 @@ public class MapMaker extends Activity {
OverlayItem item = getItem(index);
UserInfo tmpInfo = preMapInfo
.getUserInfo(markerToInt.get(item));
- String itemInfo = tmpInfo.company + "连" + tmpInfo.section + "班";
+ String itemInfo = tmpInfo.company + "连" + tmpInfo.section + "班 " + tmpInfo.nickname;
popupText.setText(itemInfo);
Bitmap bitmap = BMapUtil.getBitmapFromView(popupInfo);
popLay.showPopup(bitmap, item.getPoint(), 32);
@@ -180,15 +180,16 @@ public class MapMaker extends Activity {
}
});
int num = mOffline.scan();
- String msg = "";
+
if (num == 0) {
// msg =
// "No offline map found. It may have been loaded already or misplaced.";
} else {
- msg = String.format("Loaded %d offline maps.", num);
+ Toast.makeText(context, String.format("加载了%d个离线地图包", num),
+ Toast.LENGTH_SHORT).show();
}
Log.d("offline", "inited");
- Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
+
}
/**
@@ -266,7 +267,7 @@ public class MapMaker extends Activity {
InitLocationOverlay();
InitMyOverLay();
InitPopup();
- InitOfflineMap();
+ //InitOfflineMap();
myBM = new Drawable[20];
initMyIcons();
// InitTouchListenr();
@@ -302,6 +303,14 @@ public class MapMaker extends Activity {
}
}
+ boolean isInvalidLocation(GeoPoint point) {
+ if (point == null) return false;
+ if (point.getLatitudeE6() / 1E6 > 180.0 || point.getLatitudeE6() / 1E6 < -180.0
+ || point.getLongitudeE6() > 180.0 || point.getLongitudeE6() / 1E6 < -180.0)
+ return false;
+ return true;
+ }
+
/**
* Update to draw other users
*/
@@ -324,6 +333,11 @@ public class MapMaker extends Activity {
markerToInt.remove(hash.get(i.uid));
hash.remove(i.uid);
}
+ if (mapInfo.getUserInfo(i.uid) != null && isInvalidLocation(mapInfo.getUserInfo(i.uid).location)) {
+ mOverlay.removeItem(hash.get(i.uid));
+ markerToInt.remove(hash.get(i.uid));
+ hash.remove(i.uid);
+ }
}
}
mMapView.refresh();
@@ -334,26 +348,28 @@ public class MapMaker extends Activity {
if (i.uid == preMapInfo.myInfo.uid)
continue;
if (hash.containsKey(i.uid) == false) {
- GeoPoint p = new GeoPoint((int) (i.getLatitude() * 1E6),
- (int) (i.getLongitude() * 1E6));
- curItem = new OverlayItem(p, "USERNAME_HERE",
+ if (isInvalidLocation(i.location)) {
+
+ } else {
+ curItem = new OverlayItem(i.location, "USERNAME_HERE",
"USER_SNIPPET_HERE");
- // TODO getDrawable
- // /////////////////////////////
- curItem.setMarker(getGroupIcon(i.section));
- mOverlay.addItem(curItem);
- hash.put(i.uid, curItem);
- markerToInt.put(curItem, i.uid);
- // if (mMapView != null)
- // mMapView.refresh();
+ // TODO getDrawable
+ // /////////////////////////////
+ curItem.setMarker(getGroupIcon(i.section));
+ mOverlay.addItem(curItem);
+ hash.put(i.uid, curItem);
+ markerToInt.put(curItem, i.uid);
+ }
} else {
- GeoPoint p = new GeoPoint((int) (i.getLatitude() * 1E6),
- (int) (i.getLongitude() * 1E6));
- curItem = hash.get(i.uid);
- curItem.setGeoPoint(p);
- mOverlay.updateItem(curItem);
- // if (mMapView != null)
- // mMapView.refresh();
+ if (isInvalidLocation(i.location)) {
+ mOverlay.removeItem(hash.get(i.uid));
+ markerToInt.remove(hash.get(i.uid));
+ hash.remove(i.uid);
+ } else {
+ curItem = hash.get(i.uid);
+ curItem.setGeoPoint(i.location);
+ mOverlay.updateItem(curItem);
+ }
}
}
if (mMapView != null) {
@@ -488,20 +504,4 @@ public class MapMaker extends Activity {
clearOverlay(null);
mOverlay.addItem(mItems);
}
-
- @Override
- protected void onPause() {
- mMapView.onPause();
- }
-
- @Override
- protected void onResume() {
- mMapView.onResume();
- }
-
- @Override
- protected void onDestroy() {
- mMapView.destroy();
- }
-
}
diff --git a/client/Piztor/src/com/macaroon/piztor/Rlocation.java b/client/Piztor/src/com/macaroon/piztor/Rlocation.java
deleted file mode 100644
index c2d429c..0000000
--- a/client/Piztor/src/com/macaroon/piztor/Rlocation.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.macaroon.piztor;
-
-class Rlocation{
- int id; //id
- double latitude; //latitude
- double longitude; //longitude
-
- Rlocation(int i,double lat,double lot){
- id = i;
- latitude = lat;
- longitude = lot;
- }
-} \ No newline at end of file
diff --git a/client/Piztor/src/com/macaroon/piztor/Settings.java b/client/Piztor/src/com/macaroon/piztor/Settings.java
index ad98662..8b4a948 100644
--- a/client/Piztor/src/com/macaroon/piztor/Settings.java
+++ b/client/Piztor/src/com/macaroon/piztor/Settings.java
@@ -147,7 +147,7 @@ public class Settings extends PiztorAct {
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
if (progress == 0) progress = 1;
- refreshrate.setText(progress + "s each update");
+ refreshrate.setText(progress + "s一次更新");
currentRate = progress;
Log.d("seek", "cur " + progress);
}
@@ -237,6 +237,13 @@ public class Settings extends PiztorAct {
}
@Override
+ protected void onResume() {
+ super.onResume();
+ if (app.isExiting || app.isLogout)
+ finish();
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.setting, menu);
diff --git a/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java b/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java
index 74d1b83..ff7c00d 100644
--- a/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java
+++ b/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java
@@ -3,8 +3,10 @@ package com.macaroon.piztor;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Vector;
import android.app.Activity;
@@ -33,7 +35,6 @@ public class SubscribeSettings extends PiztorAct {
static class ReCall extends Handler {
WeakReference<SubscribeSettings> outerClass;
-
ReCall(SubscribeSettings activity) {
outerClass = new WeakReference<SubscribeSettings>(activity);
}
@@ -109,6 +110,7 @@ public class SubscribeSettings extends PiztorAct {
private EditText edit_company;
private EditText edit_section;
private Vector<RGroup> listGroup;
+ private Set<Integer> recSubcribe;
void upMapInfo(Vector<RLocation> l) {
@@ -142,28 +144,48 @@ public class SubscribeSettings extends PiztorAct {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.subscribe_settings);
+ mShowInfo = (TextView) findViewById(R.id.textView1);
+ mShowInfo.setText("若要关注整个连请将班级号留空");
+
listGroup = new Vector<RGroup>();
+ recSubcribe = new HashSet<Integer>();
+
app = (myApp) getApplication();
app.transam.setHandler(handler);
mListView = (ListView) findViewById(R.id.listView1);
edit_company = (EditText) findViewById(R.id.subscribe_company);
edit_section = (EditText) findViewById(R.id.subscribe_section);
mList = new ArrayList<HashMap<String, Object>>();
+
final MySimpleAdapter simpleAdapter = new MySimpleAdapter(this, mList,
R.layout.subscribe_item, new String[] { "subscribe_text",
"btnadd" },
new int[] { R.id.textView1, R.id.button_add });
+
mListView.setAdapter(simpleAdapter);
// TODO get current subscribe
+
for (RGroup i : ((myApp) getApplication()).sublist) {
+ if (i.section == 255)
+ recSubcribe.add(i.company);
+ }
+ for (int i : recSubcribe) {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put("subscribe_text", i + "连");
+ mList.add(map);
+
+ RGroup listItem = new RGroup(i, 255);
+ listGroup.add(listItem);
+ simpleAdapter.notifyDataSetChanged();
+ }
+ for (RGroup i : ((myApp) getApplication()).sublist) {
+ if (i.section == 255) continue;
+ //else
HashMap<String, Object> map = new HashMap<String, Object>();
- int cc = i.company;
- int ss = i.section;
-
- map.put("subscribe_text", cc + "连 " + ss + "班");
+ map.put("subscribe_text", i.company + "连 " + i.section + "班");
mList.add(map);
- RGroup listItem = new RGroup(cc, ss);
+ RGroup listItem = new RGroup(i.company, i.section);
listGroup.add(listItem);
simpleAdapter.notifyDataSetChanged();
}
@@ -172,21 +194,75 @@ public class SubscribeSettings extends PiztorAct {
@Override
public void onClick(View v) {
- int cc = Integer.parseInt(edit_company.getText().toString());
- int ss = Integer.parseInt(edit_section.getText().toString());
- HashMap<String, Object> map = new HashMap<String, Object>();
- map.put("subscribe_text", cc + "连 " + ss + "班");
- mList.add(map);
+
+ int cc,ss;
+ //Log.d("sub", edit_company.getText().toString() + " " + edit_section.getText().toString());
+ if (edit_company.getText().toString().length() == 0) {
+ mShowInfo.setText("连号为空,请输入正确的连队、班级号(关注整个连,则班号留空)");
+ Log.d("sub", "连号为空");
+ return;
+ } else {
+ cc = Integer.parseInt(edit_company.getText().toString());
+ if (cc <= 0 || cc > 40) {
+ mShowInfo.setText("连号超限,请输入正确的连队、班级号(关注整个连,则班号留空)");
+ Log.d("sub", "连号超限" + cc);
+ return;
+ }
+ }
+
+ if (edit_section.getText().toString().length() == 0) {
+ ss = 255;
+ Log.d("sub", "订阅全连" + cc);
+ } els