summaryrefslogtreecommitdiff
path: root/client/Piztor/src/com/macaroon/piztor/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'client/Piztor/src/com/macaroon/piztor/Main.java')
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java42
1 files changed, 34 insertions, 8 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index 052e267..97d2f7b 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -14,6 +14,7 @@ import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
+import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageButton;
import android.widget.Toast;
@@ -53,13 +54,14 @@ public class Main extends PiztorAct {
LocationData locData = null;
public MyLocationListener myListener = new MyLocationListener();
boolean isFirstLocation = true;
- public static int GPSrefreshrate = 5;
+ public static int GPSrefreshrate = 20;
private final int checkinRadius = 10;
ImageButton btnCheckin, btnFetch, btnFocus, btnSettings;
static class ReCall extends Handler {
WeakReference<Main> outerClass;
+ String id = "main";
ReCall(Main activity) {
outerClass = new WeakReference<Main>(activity);
@@ -71,6 +73,7 @@ public class Main extends PiztorAct {
if (out == null) {
System.out.println("act被回收了");
}
+ Log.d("marker", "what is " + m.what);
switch (m.what) {
case Res.Login:// 上传自己信息成功or失败
Log.d("update location", "successfull");
@@ -122,6 +125,7 @@ public class Main extends PiztorAct {
(int) (pushMarker.latitude * 1e6),
(int) (pushMarker.longitude * 1e6));
markerInfo.markerTimestamp = pushMarker.deadline;
+ Log.d("marker", "Marker received! " + pushMarker.deadline);
out.mapMaker.receiveMarker(markerInfo);
break;
case -1:
@@ -175,6 +179,15 @@ public class Main extends PiztorAct {
toast.show();
}
+ public void updateMyLocation() {
+ if (app.token != null) {
+ app.mapInfo.myInfo.setLocation(locData.latitude, locData.longitude);
+ transam.send(new ReqUpdate(app.token, app.username,
+ locData.latitude, locData.longitude,
+ System.currentTimeMillis(), 2000));
+ }
+ }
+
public class MyLocationListener implements BDLocationListener {
int cnt = 0;
GeoPoint lastPoint = null;
@@ -196,11 +209,7 @@ public class Main extends PiztorAct {
if (lastPoint == null || cnt > 5
|| DistanceUtil.getDistance(point, lastPoint) > 10) {
if (app.token != null) {
- app.mapInfo.myInfo.setLocation(locData.latitude,
- locData.longitude);
- transam.send(new ReqUpdate(app.token, app.username,
- locData.latitude, locData.longitude, System
- .currentTimeMillis(), 2000));
+ updateMyLocation();
lastPoint = point;
cnt = 0;
}
@@ -259,7 +268,7 @@ public class Main extends PiztorAct {
+ app.mapInfo.myInfo.uid);
}
if (e == SuccessFetch)
- flushMap();
+ { }
}
@Override
@@ -293,6 +302,7 @@ public class Main extends PiztorAct {
closeBoard(Main.this);
if (app.mapInfo.myInfo.level != 0) {
alertMaker.showMarkerAlert(arg0);
+ closeBoard(Main.this);
}
}
@@ -343,7 +353,13 @@ public class Main extends PiztorAct {
.getSystemService(LOCATION_SERVICE);
isGPSEnabled = locationManager
.isProviderEnabled(locationManager.GPS_PROVIDER);
+
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+ requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_main);
+ setProgressBarIndeterminateVisibility(true);
+ setProgressBarVisibility(true);
+
app.mBMapManager.start();
mMapView = (MapView) findViewById(R.id.bmapView);
@@ -402,7 +418,17 @@ public class Main extends PiztorAct {
actMgr.trigger(AppMgr.toSettings);
}
});
-
+
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View arg0) {
+ Toast.makeText(Main.this, "正在定位...", Toast.LENGTH_LONG).show();
+ mLocClient.requestLocation();
+ updateMyLocation();
+ focusOn();
+ }
+ });
}
@Override