aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/MapActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/MapActivity.java')
-rw-r--r--src/net/cbaines/suma/MapActivity.java63
1 files changed, 47 insertions, 16 deletions
diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java
index 07806fa..501e00d 100644
--- a/src/net/cbaines/suma/MapActivity.java
+++ b/src/net/cbaines/suma/MapActivity.java
@@ -50,6 +50,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
+import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
@@ -192,7 +193,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
Thread databaseThread = new Thread(this); // Start the database thread
databaseThread.start();
- setContentView(R.layout.main);
+ setContentView(R.layout.map_activity);
Log.i(TAG, "Finished setting content view " + (System.currentTimeMillis() - startTime));
@@ -235,7 +236,30 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
GeoPoint userLocation = null;
Bundle extras = getIntent().getExtras();
- if (extras != null && extras.containsKey("poiPoint")) {
+ if (getIntent().getDataString() != null) {
+
+ Log.i(TAG, "getIntent().getDataString() " + getIntent().getDataString());
+
+ String str = getIntent().getDataString().substring(4, getIntent().getDataString().length());
+ String[] strParts = str.split(",");
+
+ int lat = Util.doubleToIntE6(Double.valueOf(strParts[0]));
+ int lng;
+
+ if (strParts[1].contains("?")) {
+ String zoom = strParts[1].substring(strParts[1].indexOf("?") + 3, strParts[1].length());
+ String strLng = strParts[1].substring(0, strParts[1].indexOf("?") - 1);
+ lng = Util.doubleToIntE6(Double.valueOf(strLng));
+
+ mapController.setZoom(Integer.valueOf(zoom));
+ } else {
+ lng = Util.doubleToIntE6(Double.valueOf(strParts[1]));
+ mapController.setZoom(15);
+ }
+
+ userLocation = new GeoPoint(lat, lng);
+
+ } else if (extras != null && extras.containsKey("poiPoint")) {
String poiPoint = getIntent().getExtras().getString("poiPoint");
Log.i(TAG, "poiPoint " + poiPoint);
@@ -360,7 +384,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao();
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao();
long busStopCount = busStopDao.countOf();
long busRouteCount = busRouteDao.countOf();
@@ -1059,15 +1083,6 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
- /*
- * public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- *
- * mapView.post(new Runnable() { public void run() { // updateEnabledOverlays(); TODO Fix whatever this did?
- * mapView.invalidate(); } });
- *
- * return true; }
- */
-
protected Dialog onCreateDialog(int id) {
switch (id) {
case VIEW_DIALOG_ID:
@@ -1156,10 +1171,26 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
Log.i(TAG, "Pressed " + busStop.id);
- Intent i = new Intent(this, BusStopActivity.class);
- i.putExtra("busStopID", busStop.id);
- i.putExtra("busStopName", busStop.description);
- startActivityForResult(i, 0);
+ Uri uri = Uri.parse("http://id.southampton.ac.uk/bus-stop/" + busStop.id);
+
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent busStopIntent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(busStopIntent);
+
+ return true;
+
+ } else if (poi.type == POI.BUILDING) {
+ Building building = (Building) poi;
+
+ Log.i(TAG, "Pressed " + building.id);
+
+ Uri uri = Uri.parse("http://id.southampton.ac.uk/building/" + building.id);
+
+ Log.i(TAG, "Starting a activity for " + uri + " path " + uri.getPath());
+
+ Intent buildingIntent = new Intent(Intent.ACTION_VIEW, uri);
+ startActivity(buildingIntent);
return true;