summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsjtufs <sjtu_fs@outlook.com>2013-08-28 23:20:56 +0800
committersjtufs <sjtu_fs@outlook.com>2013-08-28 23:20:56 +0800
commit956c10597fa5e504eab9255a5fde61a54c6f1972 (patch)
tree2bce814f71cadfb0cd35c44bd2ca33477712f7cf
parent85476a061cc854014d28b96690b160843fe95e60 (diff)
final version of 20130828 from lym and fs
-rw-r--r--client/Piztor/res/drawable/circle_green.pngbin0 -> 1079 bytes
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java71
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapMaker.java10
3 files changed, 51 insertions, 30 deletions
diff --git a/client/Piztor/res/drawable/circle_green.png b/client/Piztor/res/drawable/circle_green.png
new file mode 100644
index 0000000..ded6938
--- /dev/null
+++ b/client/Piztor/res/drawable/circle_green.png
Binary files differ
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index 5aa767d..03e7ebc 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -4,8 +4,6 @@ import java.util.Timer;
import java.util.TimerTask;
import android.annotation.SuppressLint;
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -21,15 +19,10 @@ import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
-import com.baidu.mapapi.map.ItemizedOverlay;
import com.baidu.mapapi.map.LocationData;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayItem;
-import com.baidu.mapapi.map.PopupClickListener;
import com.baidu.mapapi.map.PopupOverlay;
-import com.baidu.platform.comapi.basestruct.GeoPoint;
-
-import com.macaroon.piztor.BMapUtil;
public class Main extends PiztorAct {
final static int SearchButtonPress = 1;
@@ -39,9 +32,23 @@ public class Main extends PiztorAct {
final static int Fetch = 6;
final static int mapViewtouched = 7;
+ /**
+ * popups
+ */
+ private PopupOverlay pop = null;
+ private TextView popupText = null;
+ private View viewCache = null;
+ private View popupInfo = null;
+ private View popupLeft = null;
+ private View popupRight = null;
+ private MapView.LayoutParams layoutParam = null;
+ private OverlayItem mCurItem = null;
+
MapMaker mapMaker = null;
MapView mMapView;
+ boolean isFirstLocation = true;
+
/**
* Locating component
*/
@@ -50,7 +57,7 @@ public class Main extends PiztorAct {
public MyLocationListener myListener = new MyLocationListener();
ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
- //Timer autodate;
+ // Timer autodate;
MapInfo mapInfo;
/*
* @SuppressLint("HandlerLeak") Handler fromGPS = new Handler() {
@@ -100,11 +107,7 @@ public class Main extends PiztorAct {
+ " group : " + r.gid);
if (r.uid == Infomation.myInfo.uid) {
Infomation.myInfo.gid = r.gid;
- try {
- //autodate.schedule(new AutoUpdate(), 0, 5000);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ Infomation.myInfo.sex = r.sex;
} else {
UserInfo user = mapInfo.getUserInfo(r.uid);
if (user != null)
@@ -119,9 +122,14 @@ public class Main extends PiztorAct {
}
break;
case 4:// 登出
- Toast toast = Toast.makeText(getApplicationContext(),
- "logout failed", Toast.LENGTH_LONG);
- toast.show();
+ ResLogout logout = (ResLogout) m.obj;
+ if (logout.s == 0) {
+ actMgr.trigger(AppMgr.logout);
+ } else {
+ Toast toast = Toast.makeText(getApplicationContext(),
+ "logout failed", Toast.LENGTH_LONG);
+ toast.show();
+ }
break;
default:
break;
@@ -150,6 +158,9 @@ public class Main extends PiztorAct {
void flushMap() {
if (mapMaker != null)
mapMaker.UpdateMap(AppMgr.mapInfo);
+ else
+ System.out
+ .println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
public class MyLocationListener implements BDLocationListener {
@@ -165,9 +176,14 @@ public class Main extends PiztorAct {
locData.accuracy = location.getRadius();
locData.direction = location.getDerect();
- mapMaker.UpdateLocationOverlay(locData, false);
- if (Infomation.token != null)
- AppMgr.transam.send(new ReqUpdate(Infomation.token, Infomation.username, locData.latitude, locData.longitude, System.currentTimeMillis(), 2000));
+ mapMaker.UpdateLocationOverlay(locData, isFirstLocation);
+ isFirstLocation = false;
+ if (Infomation.token != null) {
+ AppMgr.transam.send(new ReqUpdate(Infomation.token,
+ Infomation.username, locData.latitude,
+ locData.longitude, System.currentTimeMillis(), 2000));
+ Infomation.myInfo.setLocation(locData.latitude, locData.longitude);
+ }
}
@Override
@@ -236,9 +252,7 @@ public class Main extends PiztorAct {
requesLocation(Infomation.myInfo.gid);
break;
case FocuseButtonPress:
- if( locData != null) {
- mapMaker.UpdateLocationOverlay(locData, true);
- } else mapMaker.InitMap();
+ mapMaker.UpdateLocationOverlay(locData, true);
break;
case SuccessFetch:
flushMap();
@@ -293,16 +307,13 @@ public class Main extends PiztorAct {
actMgr.add(focusStatus, mapViewtouched, startStatus);
actMgr.add(focusStatus, SuccessFetch, focusStatus);
actMgr.add(focusStatus, Fetch, focusStatus);
- //autodate = new Timer();
- flushMap();
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.bmapView);
mapMaker = new MapMaker(mMapView, getApplicationContext());
+ mapMaker.clearOverlay(mMapView);
mapMaker.InitMap();
mLocClient = new LocationClient(this);
locData = new LocationData();
- locData.latitude = 31.032247;
- locData.longitude = 121.445937;
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);
@@ -313,6 +324,10 @@ public class Main extends PiztorAct {
mapMaker.UpdateLocationOverlay(locData, false);
}
+ /*
+ * public boolean onTap(int index) { OverlayItem item = getItem(index);
+ * mCurItem = item; if () }
+ */
@Override
protected void onStart() {
super.onStart();
@@ -344,6 +359,7 @@ public class Main extends PiztorAct {
@Override
protected void onResume() {
mapMaker.onResume();
+ flushMap();
super.onResume();
}
@@ -356,7 +372,6 @@ public class Main extends PiztorAct {
@Override
public void onStop() {
super.onStop();
- //autodate.cancel();
}
@Override
@@ -397,4 +412,4 @@ public class Main extends PiztorAct {
mMapView.onRestoreInstanceState(savedInstanceState);
}
-}
+} \ No newline at end of file
diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
index 8af00ea..4e30df6 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
@@ -261,7 +261,8 @@ public class MapMaker extends Activity {
mOverlay = new MyOverlay(context.getResources().getDrawable(R.drawable.circle_red), mMapView);
GeoPoint p;
Vector<UserInfo> allUsers = mapInfo.getVector();
- for (int i = 0; i < allUsers.size(); i++) {
+ boolean flag = false;
+ for (int i =1; i < allUsers.size(); i++) {
// it's me!
if (allUsers.get(i).uid == Infomation.myInfo.uid) continue;
p = new GeoPoint((int)(allUsers.get(i).getLatitude() * 1E6),
@@ -269,7 +270,12 @@ public class MapMaker extends Activity {
curItem = new OverlayItem(p, "USERNAME HERE!!!!!", "");
//TODO
////////////////////////////////////////////////////////////
- curItem.setMarker(context.getResources().getDrawable(R.drawable.circle_red));
+ if (flag == false){
+ flag = true;
+ curItem.setMarker(context.getResources().getDrawable(R.drawable.circle_green));
+ } else {
+ curItem.setMarker(context.getResources().getDrawable(R.drawable.circle_red));
+ }
mOverlay.addItem(curItem);
}
mItems = new ArrayList<OverlayItem>();