Skip to content
Browse files

Support for back key pointing to host info page (#31).

Switch off GPS when pausing activity. Closes #32.
  • Loading branch information...
1 parent e15d214 commit 74ccc8aee16d2f9a85603ea128c9168abf3605dc @jstaffans committed Apr 5, 2012
Showing with 27 additions and 1 deletion.
  1. +27 −1 src/fi/bitrite/android/ws/activity/MapSearchTabActivity.java
View
28 src/fi/bitrite/android/ws/activity/MapSearchTabActivity.java
@@ -67,6 +67,10 @@
HostBriefInfo host;
Dialog hostPopup;
+ boolean cameFromHostInfo;
+ Host savedHost;
+ int savedHostId;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -76,6 +80,7 @@ protected void onCreate(Bundle savedInstanceState) {
mapController = mapView.getController();
gson = new Gson();
setupHostPopup();
+ cameFromHostInfo = false;
}
private void setupHostPopup() {
@@ -306,15 +311,29 @@ private void hideBigNumberOfHosts() {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == HostInformationActivity.RESULT_SHOW_HOST_ON_MAP) {
+ MainActivity parent = (MainActivity) getParent();
+ parent.stashHost(data, 2);
int lat = data.getIntExtra("lat", mapView.getMapCenter().getLatitudeE6());
int lon = data.getIntExtra("lon", mapView.getMapCenter().getLongitudeE6());
GeoPoint point = new GeoPoint(lat, lon);
mapController.animateTo(point);
mapController.setZoom(16);
mapView.invalidate();
- }
+ }
}
+ @Override
+ public void onBackPressed() {
+ MainActivity parent = (MainActivity) getParent();
+ if (parent.hasStashedHost()) {
+ Intent i = new Intent(MapSearchTabActivity.this, HostInformationActivity.class);
+ i = parent.popStashedHost(i);
+ startActivityForResult(i, 0);
+ } else {
+ super.onBackPressed();
+ }
+ }
+
public void zoomToCurrentLocation(View view) {
if (locationOverlay.getMyLocation() != null) {
mapController.animateTo(locationOverlay.getMyLocation());
@@ -330,6 +349,11 @@ protected boolean isRouteDisplayed() {
@Override
protected void onResume() {
super.onResume();
+ locationOverlay.enableMyLocation();
+ animateToMapTargetIfNeeded();
+ }
+
+ private void animateToMapTargetIfNeeded() {
GeoPoint target = mapAnimator.getTarget();
if (target != null && target.getLatitudeE6() != 0 && target.getLongitudeE6() != 0) {
mapController.animateTo(target);
@@ -342,5 +366,7 @@ protected void onResume() {
protected void onPause() {
super.onPause();
mapAnimator.clearTarget();
+ locationOverlay.disableMyLocation();
}
+
}

0 comments on commit 74ccc8a

Please sign in to comment.
Something went wrong with that request. Please try again.