aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java5
-rw-r--r--src/net/cbaines/suma/DataManager.java89
-rw-r--r--src/net/cbaines/suma/MapActivity.java254
-rw-r--r--src/net/cbaines/suma/POIArrayAdapter.java2
-rw-r--r--src/net/cbaines/suma/SearchResultsActivity.java (renamed from src/net/cbaines/suma/SearchActivity.java)2
5 files changed, 183 insertions, 169 deletions
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index b80d5b4..e28086a 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -308,7 +308,7 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha
return timetable;
}
- private class GetTimetableTask extends AsyncTask<String, Integer, Timetable> {
+ private class GetTimetableTask extends AsyncTask<String, Integer, Timetable> {
String errorMessage;
protected void onPreExecute() {
@@ -337,7 +337,8 @@ public class BusStopActivity extends ToastHelperActivity implements OnCheckedCha
errorMessage = "Error parsing bus times";
e.printStackTrace();
} catch (Exception e) {
- Log.e(TAG, e.getMessage(), e.getCause());
+ Log.e(TAG, "Exception in new timetable " + e.getMessage(), e.getCause());
+ e.printStackTrace();
}
return newTimetable;
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index 082631c..ca27672 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -187,13 +187,9 @@ public class DataManager {
/*
* Polygon poly = buildingPolys.get(dataBits[1]);
*
- * if (poly != null) { bdg.outline = poly; // Log.i(TAG,
- * "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6() + " " + poly); } else { //
- * Log.i(TAG, "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6()); }
+ * if (poly != null) { bdg.outline = poly; // Log.i(TAG, "Adding building " + key + " " +
+ * bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG,
+ * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6()); }
*/
// Log.i(TAG, "Creating building " + bdg.id + " " + bdg.name
@@ -217,13 +213,9 @@ public class DataManager {
/*
* Polygon poly = buildingPolys.get(dataBits[1]);
*
- * if (poly != null) { bdg.outline = poly; // Log.i(TAG,
- * "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6() + " " + poly); } else { //
- * Log.i(TAG, "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6()); }
+ * if (poly != null) { bdg.outline = poly; // Log.i(TAG, "Adding building " + key + " " +
+ * bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG,
+ * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6()); }
*/
// Log.i(TAG, "Creating building " + bdg.id + " " + bdg.name
@@ -242,17 +234,13 @@ public class DataManager {
}
/*
- * for (Iterator<String> iter = buildingPoints.keySet().iterator();
- * iter.hasNext();) { String key = iter.next();
+ * for (Iterator<String> iter = buildingPoints.keySet().iterator(); iter.hasNext();) { String key = iter.next();
*
- * Building bdg = new Building(key, buildingPoints.get(key), false);
- * Polygon poly = buildingPolys.get(key);
+ * Building bdg = new Building(key, buildingPoints.get(key), false); Polygon poly = buildingPolys.get(key);
*
- * if (poly != null) { bdg.outline = poly; // Log.i(TAG,
- * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG,
- * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6()); }
+ * if (poly != null) { bdg.outline = poly; // Log.i(TAG, "Adding building " + key + " " + bdg.point.getLatitudeE6() + " "
+ * + bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG, "Adding building " + key + " " +
+ * bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6()); }
*
* buildingDao.create(bdg); }
*/
@@ -289,18 +277,18 @@ public class DataManager {
// Log.i(TAG, "Whole " + dataBits[3] + " First bit " +
// quBitsLat[0] + " last bit " + quBitsLat[1]);
- double lat = Double.valueOf(quBitsLat[0])
- + Double.valueOf(quBitsLat[1].substring(0, quBitsLat[1].length() - 1)) / 60d;
+ double lat = Double.valueOf(quBitsLat[0]) + Double.valueOf(quBitsLat[1].substring(0, quBitsLat[1].length() - 1))
+ / 60d;
// Log.i(TAG, "Whole " + dataBits[4] + " First bit " +
// quBitsLng[0] + " last bit " + quBitsLng[1]);
- double lng = Double.valueOf(quBitsLng[0])
- + Double.valueOf(quBitsLng[1].substring(0, quBitsLng[1].length() - 1)) / 60d;
+ double lng = Double.valueOf(quBitsLng[0]) + Double.valueOf(quBitsLng[1].substring(0, quBitsLng[1].length() - 1))
+ / 60d;
GeoPoint point = new GeoPoint((int) (lat * 1e6), (int) (lng * -1e6));
// Log.i(TAG, "Lat " + point.getLatitudeE6() + " lng " +
// point.getLongitudeE6());
- busStopDao.create(new BusStop(dataBits[0].replace("\"", ""), dataBits[1].replace("\"", ""), dataBits[2]
- .replace("\"", ""), point));
+ busStopDao.create(new BusStop(dataBits[0].replace("\"", ""), dataBits[1].replace("\"", ""), dataBits[2].replace(
+ "\"", ""), point));
}
@@ -421,36 +409,26 @@ public class DataManager {
}
/*
- * for (Iterator<BusStop> busStopIter = busStopDao.iterator();
- * busStopIter.hasNext();) { BusStop stop = busStopIter.next(); //
- * Log.i(TAG, "Looking at stop " + stop.id);
+ * for (Iterator<BusStop> busStopIter = busStopDao.iterator(); busStopIter.hasNext();) { BusStop stop =
+ * busStopIter.next(); // Log.i(TAG, "Looking at stop " + stop.id);
*
*
- * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder =
- * routeStopsDao.queryBuilder();
+ * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
* routeStopsQueryBuilder.where().eq(columnName, value)
*
- * DeleteBuilder<BusStop, String> deleteBuilder =
- * busStopDao.deleteBuilder(); // only delete the rows where password is
- * null deleteBuilder.where().in(RouteStops.STOP_ID_FIELD_NAME, objects)
- * accountDao.delete(deleteBuilder.prepare());
+ * DeleteBuilder<BusStop, String> deleteBuilder = busStopDao.deleteBuilder(); // only delete the rows where password is
+ * null deleteBuilder.where().in(RouteStops.STOP_ID_FIELD_NAME, objects) accountDao.delete(deleteBuilder.prepare());
*
*
- * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder =
- * routeStopsDao.queryBuilder();
- * routeStopsQueryBuilder.setCountOf(true);
- * routeStopsQueryBuilder.where().eq(RouteStops.STOP_ID_FIELD_NAME,
- * stop);
+ * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ * routeStopsQueryBuilder.setCountOf(true); routeStopsQueryBuilder.where().eq(RouteStops.STOP_ID_FIELD_NAME, stop);
*
- * PreparedQuery<RouteStops> routeStopsPreparedQuery =
- * routeStopsQueryBuilder.prepare(); List<RouteStops> routeStops =
- * routeStopsDao.query(routeStopsPreparedQuery); // long num =
- * routeStopsDao.query(routeStopsPreparedQuery).size(); // Log.i(TAG,
- * "Number is " + num);
+ * PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); List<RouteStops> routeStops =
+ * routeStopsDao.query(routeStopsPreparedQuery); // long num = routeStopsDao.query(routeStopsPreparedQuery).size(); //
+ * Log.i(TAG, "Number is " + num);
*
- * stop.uniLink = false; for (RouteStops routeStop : routeStops) { if
- * (routeStop.busRoute.uniLink) { stop.uniLink = true; } }
- * busStopDao.update(stop); }
+ * stop.uniLink = false; for (RouteStops routeStop : routeStops) { if (routeStop.busRoute.uniLink) { stop.uniLink = true;
+ * } } busStopDao.update(stop); }
*/
Log.i(TAG, "Finished loading bus data");
@@ -512,6 +490,8 @@ public class DataManager {
routeStopsDao = helper.getRouteStopsDao();
if (busStopDao == null)
busStopDao = helper.getBusStopDao();
+ if (busDao == null)
+ busDao = helper.getBusDao();
String time = stopObj.getString("time");
@@ -628,8 +608,7 @@ public class DataManager {
// " stops matching the destStop " + destStop + " on route " +
// route.code);
} else {
- Log.w(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route "
- + route.code);
+ Log.w(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " + route.code);
}
}
@@ -715,8 +694,8 @@ public class DataManager {
if (route != null) {
busRoutes.add(route);
} else {
- throw new RuntimeException("Route not found " + key.substring(key.length() - 3, key.length()) + " "
- + key);
+ Log.e(TAG, "Route not found " + key.substring(key.length() - 3, key.length()) + " " + key);
+ throw new RuntimeException("Route not found " + key.substring(key.length() - 3, key.length()) + " " + key);
}
}
diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java
index 3b8efe5..2bdc3d7 100644
--- a/src/net/cbaines/suma/MapActivity.java
+++ b/src/net/cbaines/suma/MapActivity.java
@@ -64,18 +64,20 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import com.j256.ormlite.dao.Dao;
+import com.j256.ormlite.stmt.PreparedQuery;
+import com.j256.ormlite.stmt.QueryBuilder;
/**
*
* @author Christopher Baines <cbaines8@gmail.com>
*
*/
-public class MapActivity extends ToastHelperActivity implements MapViewConstants, RouteColorConstants,
- OnItemClickListener, OnItemLongClickListener, OnSharedPreferenceChangeListener, Preferences {
+public class MapActivity extends ToastHelperActivity implements MapViewConstants, RouteColorConstants, OnItemClickListener,
+ OnItemLongClickListener, OnSharedPreferenceChangeListener, Preferences {
/**
- * Enable to use the database in the assets folder, if its not enabled, the
- * database is built from the csv files in the assets folder
+ * Enable to use the database in the assets folder, if its not enabled, the database is built from the csv files in the assets
+ * folder
*/
private boolean useBundledDatabase = true;
@@ -88,6 +90,9 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
static final int VIEW_DIALOG_ID = 0;
static final int FAVOURITE_DIALOG_ID = 1;
static final int WELCOME_DIALOG_ID = 2;
+ static final int SEARCH_RESULTS_DIALOG_ID = 3;
+
+ private ArrayList<POI> searchResults = null;
private POIDialog favDialog;
@@ -127,11 +132,10 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
private static final int NON_UNI_LINK_BUS_STOP_OVERLAY_RANK = 4;
// -- Site Overlays
- static final String[] SITE_NAMES = { "Highfield Campus", "Boldrewood Campus", "Avenue Campus",
- "Winchester School of Art", "The University of Southampton Science Park",
- "National Oceanography Centre Campus", "Boat House", "Southampton General Hospital",
- "Royal South Hants Hospital", "Belgrave Industrial Site", "Highfield Hall", "Glen Eyre Hall",
- "South Hill Hall", "Chamberlain Hall", "Hartley Grove", "Bencraft Hall", "Connaught Hall",
+ static final String[] SITE_NAMES = { "Highfield Campus", "Boldrewood Campus", "Avenue Campus", "Winchester School of Art",
+ "The University of Southampton Science Park", "National Oceanography Centre Campus", "Boat House",
+ "Southampton General Hospital", "Royal South Hants Hospital", "Belgrave Industrial Site", "Highfield Hall",
+ "Glen Eyre Hall", "South Hill Hall", "Chamberlain Hall", "Hartley Grove", "Bencraft Hall", "Connaught Hall",
"Montefiore Hall", "Stoneham Hall", "Erasmus Park" };
private static final String SITE_OVERLAYS = "siteOverlays:";
@@ -169,14 +173,16 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
// Uni-Link routes
static final String[] UNI_LINK_ROUTES = { "U1", "U1N", "U2", "U6", "U9" };
- static final String[] PREFERENCES_GROUPS = { BUS_STOP_OVERLAYS, BUS_ROUTE_OVERLAYS, BUILDING_OVERLAYS,
- SITE_OVERLAYS, OTHER_OVERLAYS };
+ static final String[] PREFERENCES_GROUPS = { BUS_STOP_OVERLAYS, BUS_ROUTE_OVERLAYS, BUILDING_OVERLAYS, SITE_OVERLAYS,
+ OTHER_OVERLAYS };
static final String[][] PREFERENCES_CHILDREN = { UNI_LINK_ROUTES, UNI_LINK_ROUTES, BUILDING_TYPES, SITE_NAMES,
OTHER_OVERLAY_NAMES };
private MapActivity instance;
+ private POIDialog searchResultsDialog;
+
private static final String TAG = "MapActivity";
@SuppressWarnings("unchecked")
@@ -187,19 +193,6 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
instance = this;
- Intent intent = getIntent();
- Bundle extras = intent.getExtras();
-
- if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
- String query = intent.getStringExtra(SearchManager.QUERY);
-
- Intent searchIntent = new Intent(instance, SearchActivity.class);
- searchIntent.setAction(Intent.ACTION_SEARCH);
- searchIntent.putExtra(SearchManager.QUERY, query);
- startActivity(searchIntent);
-
- }
-
Log.i(TAG, "Begining loading database " + (System.currentTimeMillis() - startTime));
DatabaseHelper helper = getHelper();
@@ -252,10 +245,8 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
pastOverlays = (HashMap<String, Overlay>) getLastNonConfigurationInstance();
/*
- * SensorManager mSensorManager = (SensorManager)
- * getSystemService(Context.SENSOR_SERVICE); This code in the following
- * constructor causes problems in some emulators, disable sensors to
- * fix.
+ * SensorManager mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); This code in the following
+ * constructor causes problems in some emulators, disable sensors to fix.
*/
Log.i(TAG, "Starting creating myLocationOverlay");
myLocationOverlay = new MyLocationOverlay(instance, mapView);
@@ -279,7 +270,45 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
GeoPoint startLocation = null;
- if (getIntent().getDataString() != null) {
+ Intent intent = getIntent();
+ Bundle extras = intent.getExtras();
+
+ if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
+ String query = intent.getStringExtra(SearchManager.QUERY);
+
+ searchResults = new ArrayList<POI>();
+
+ try {
+ Dao<Building, String> buildingDao = getHelper().getBuildingDao();
+
+ QueryBuilder<Building, String> buildingQueryBuilder = buildingDao.queryBuilder();
+ buildingQueryBuilder.where().like(Building.ID_FIELD_NAME, "%" + query + "%").or()
+ .like(Building.NAME_FIELD_NAME, "%" + query + "%");
+ PreparedQuery<Building> buildingPreparedQuery = buildingQueryBuilder.prepare();
+ List<Building> buildings = buildingDao.query(buildingPreparedQuery);
+ searchResults.addAll(buildings);
+ buildings = null;
+
+ Dao<BusStop, String> busStopDao = getHelper().getBusStopDao();
+
+ QueryBuilder<BusStop, String> busStopQueryBuilder = busStopDao.queryBuilder();
+ busStopQueryBuilder.where().like(BusStop.ID_FIELD_NAME, "%" + query + "%").or()
+ .like(BusStop.DESCRIPTION_FIELD_NAME, "%" + query + "%");
+ PreparedQuery<BusStop> busStopPreparedQuery = busStopQueryBuilder.prepare();
+ List<BusStop> busStops = busStopDao.query(busStopPreparedQuery);
+ searchResults.addAll(busStops);
+ busStops = null;
+
+ startLocation = new GeoPoint(50935551, -1393488);
+ mapController.setZoom(15);
+
+ showDialog(SEARCH_RESULTS_DIALOG_ID);
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ } else if (intent.getDataString() != null) {
String dataString = getIntent().getDataString();
Log.i(TAG, "getIntent().getDataString() " + dataString);
@@ -453,8 +482,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
if (scaleBarOverlay != null) {
Log.v(TAG, "ScaleBarOverlay is already created");
} else {
- if (pastOverlays != null
- && (scaleBarOverlay = (ScaleBarOverlay) pastOverlays.get(SCALE_BAR_OVERLAY)) != null) {
+ if (pastOverlays != null && (scaleBarOverlay = (ScaleBarOverlay) pastOverlays.get(SCALE_BAR_OVERLAY)) != null) {
Log.i(TAG, "Finished restoring utility overlays " + (System.currentTimeMillis() - startTime));
} else {
scaleBarOverlay = new ScaleBarOverlay(instance);
@@ -483,8 +511,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
private void showRouteOverlay(final BusRoute route) {
new Thread(new Runnable() {
public void run() {
- Log.i(TAG, "Begining showing route " + route.code + " overlay at "
- + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Begining showing route " + route.code + " overlay at " + (System.currentTimeMillis() - startTime));
final SharedPreferences activityPrefs = getPreferences(0);
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
@@ -509,8 +536,8 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
// TODO Is this a route like U1N or, something else,
// this hack works somewhat for now?
- PathOverlay routeOverlayU1E = DataManager.getRoutePath(
- getResources().openRawResource(R.raw.u1e), colour, mResourceProxy);
+ PathOverlay routeOverlayU1E = DataManager.getRoutePath(getResources().openRawResource(R.raw.u1e),
+ colour, mResourceProxy);
routeOverlayU1E.getPaint().setAntiAlias(true);
routeOverlayU1E.getPaint().setAlpha(145);
routeOverlayU1E.getPaint().setStrokeWidth(12);
@@ -565,8 +592,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
mapView.postInvalidate();
- Log.i(TAG, "Finished showing route " + route.code + " overlay at "
- + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Finished showing route " + route.code + " overlay at " + (System.currentTimeMillis() - startTime));
}
}).start();
}
@@ -575,8 +601,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
new Thread(new Runnable() {
public void run() {
- Log.i(TAG, "Begining showing site " + site.name + " overlay at "
- + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Begining showing site " + site.name + " overlay at " + (System.currentTimeMillis() - startTime));
final SharedPreferences activityPrefs = getPreferences(0);
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
@@ -585,8 +610,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
if ((siteOverlay = siteOverlays.get(site)) != null) {
} else {
- if (pastOverlays != null
- && (siteOverlay = (PathOverlay) pastOverlays.get(SITE_OVERLAYS + site.name)) != null) {
+ if (pastOverlays != null && (siteOverlay = (PathOverlay) pastOverlays.get(SITE_OVERLAYS + site.name)) != null) {
Log.i(TAG, "Restored " + site.name + " site overlay");
} else {
@@ -612,13 +636,11 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
}
}
- siteOverlay.setEnabled(activityPrefs.getBoolean(SITE_OVERLAYS + site.name,
- SITE_OVERLAYS_ENABLED_BY_DEFAULT));
+ siteOverlay.setEnabled(activityPrefs.getBoolean(SITE_OVERLAYS + site.name, SITE_OVERLAYS_ENABLED_BY_DEFAULT));
mapView.postInvalidate();
- Log.i(TAG, "Finished showing site " + site.name + " overlay at "
- + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Finished showing site " + site.name + " overlay at " + (System.currentTimeMillis() - startTime));
}
}).start();
}
@@ -635,10 +657,8 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
} else {
if (pastOverlays != null
- && (residentialBuildingOverlay = (BuildingNumOverlay) pastOverlays
- .get(RESIDENTIAL_BUILDING_OVERLAY)) != null) {
- nonResidentialBuildingOverlay = (BuildingNumOverlay) pastOverlays
- .get(NON_RESIDENTIAL_BUILDING_OVERLAY);
+ && (residentialBuildingOverlay = (BuildingNumOverlay) pastOverlays.get(RESIDENTIAL_BUILDING_OVERLAY)) != null) {
+ nonResidentialBuildingOverlay = (BuildingNumOverlay) pastOverlays.get(NON_RESIDENTIAL_BUILDING_OVERLAY);
Log.i(TAG, "Restored building overlays");
} else {
@@ -653,8 +673,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
buildingDao = getHelper().getBuildingDao();
- final SharedPreferences favouritesPrefs = getSharedPreferences(FAVOURITES_PREFERENCES,
- MODE_PRIVATE);
+ final SharedPreferences favouritesPrefs = getSharedPreferences(FAVOURITES_PREFERENCES, MODE_PRIVATE);
for (Building building : buildingDao) {
if (building.residential == true) {
@@ -692,8 +711,8 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
}
}
- residentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(BUILDING_OVERLAYS
- + RESIDENTIAL_BUILDING_OVERLAY, RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT));
+ residentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(BUILDING_OVERLAYS + RESIDENTIAL_BUILDING_OVERLAY,
+ RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT));
nonResidentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(BUILDING_OVERLAYS
+ NON_RESIDENTIAL_BUILDING_OVERLAY, NON_RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT));
@@ -713,16 +732,11 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
final OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
if (uniLinkBusStopOverlay != null) {
- if (!activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
+ if (!activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ && !activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
Log.i(TAG, "Uni-Link bus stop overlay not needed");
overlays.remove(UNI_LINK_BUS_STOP_OVERLAY);
@@ -733,31 +747,25 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
uniLinkBusStopOverlay = null;
} else {
- uniLinkBusStopOverlay.setRoutes(0, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(1, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(2, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(3, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(4, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(0,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(1,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(2,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(3,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(4,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
}
} else {
- if (activityPrefs
- .getBoolean(BUS_STOP_OVERLAYS + "U1", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
- || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
+ if (activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)
+ || activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
if (pastOverlays != null
- && (uniLinkBusStopOverlay = (BusStopOverlay) pastOverlays
- .get(UNI_LINK_BUS_STOP_OVERLAY)) != null) {
+ && (uniLinkBusStopOverlay = (BusStopOverlay) pastOverlays.get(UNI_LINK_BUS_STOP_OVERLAY)) != null) {
Log.i(TAG, "Restored Uni-Link bus stop overlay");
} else {
@@ -775,16 +783,16 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
}
}
- uniLinkBusStopOverlay.setRoutes(0, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(1, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(2, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(3, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
- uniLinkBusStopOverlay.setRoutes(4, activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9",
- UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(0,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(1,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U1N", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(2,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U2", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(3,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U6", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
+ uniLinkBusStopOverlay.setRoutes(4,
+ activityPrefs.getBoolean(BUS_STOP_OVERLAYS + "U9", UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT));
overlays.put(UNI_LINK_BUS_STOP_OVERLAY, uniLinkBusStopOverlay);
@@ -807,8 +815,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
private void showNonUniLinkBusStopOverlay() {
new Thread(new Runnable() {
public void run() {
- Log.i(TAG, "Begining showing non uni link bus stop overlays at "
- + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Begining showing non uni link bus stop overlays at " + (System.currentTimeMillis() - startTime));
// final SharedPreferences activityPrefs = getPreferences(0);
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(instance);
@@ -825,14 +832,12 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
} else if (sharedPrefs.getBoolean(NON_UNI_LINK_BUS_STOPS_OVERLAY,
NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT)) {
if (pastOverlays != null
- && (nonUniLinkBusStopOverlay = (BusStopOverlay) pastOverlays
- .get(NON_UNI_LINK_BUS_STOPS_OVERLAY)) != null) {
+ && (nonUniLinkBusStopOverlay = (BusStopOverlay) pastOverlays.get(NON_UNI_LINK_BUS_STOPS_OVERLAY)) != null) {
Log.i(TAG, "Restored non Uni-Link bus stop overlays");
} else {
try {
List<BusStop> busStops;
- Log.v(TAG, "Begin fetching non Uni-Link BusStops at "
- + (System.currentTimeMillis() - startTime));
+ Log.v(TAG, "Begin fetching non Uni-Link BusStops at " + (System.currentTimeMillis() - startTime));
busStops = getHelper().getBusStopDao().queryForEq(BusStop.UNI_LINK_FIELD_NAME, false);
@@ -862,8 +867,7 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
mapView.postInvalidate();
- Log.i(TAG, "Finished showing non Uni-Link bus stop overlays at "
- + (System.currentTimeMillis() - startTime));
+ Log.i(TAG, "Finished showing non Uni-Link bus stop overlays at " + (System.currentTimeMillis() - startTime));
}
}).start();
}
@@ -914,9 +918,8 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage("GPS is not enabled, do you wish to enable it?")
- .setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener)
- .show();
+ builder.setMessage("GPS is not enabled, do you wish to enable it?").setPositiveButton("Yes", dialogClickListener)
+ .setNegativeButton("No", dialogClickListener).show();
}
return true;
@@ -1037,6 +1040,13 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
favDialog.setOnItemLongClickListener(this);
favDialog.setTitle(R.string.favourites_dialog_title);
return favDialog;
+ case SEARCH_RESULTS_DIALOG_ID:
+ searchResultsDialog = new POIDialog(instance);
+ searchResultsDialog.setOnItemClickListener(this);
+ searchResultsDialog.setOnItemLongClickListener(this);
+ searchResultsDialog.setTitle(R.string.search_results_dialog_title);
+ searchResultsDialog.setItems(searchResults);
+ return searchResultsDialog;
case WELCOME_DIALOG_ID:
WelcomeDialog welcomeDialog = new WelcomeDialog(instance);
return welcomeDialog;
@@ -1047,7 +1057,12 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.i(TAG, "OnItemClick pos " + position + " id " + id);
- String poiId = favDialog.adapter.getItemStringId(position);
+ String poiId = null;
+ if (favDialog != null) {
+ poiId = favDialog.adapter.getItemStringId(position);
+ } else if (searchResultsDialog != null) {
+ poiId = searchResultsDialog.adapter.getItemStringId(position);
+ }
Log.i(TAG, "POI " + poiId + " selected");
@@ -1073,7 +1088,13 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
mapController.setZoom(20);
mapController.setCenter(poi.point);
- favDialog.dismiss();
+ if (favDialog != null) {
+ favDialog.dismiss();
+ favDialog = null;
+ } else if (searchResultsDialog != null) {
+ searchResultsDialog.dismiss();
+ searchResultsDialog = null;
+ }
}
} else {
@@ -1092,7 +1113,12 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
Log.i(TAG, "OnItemClick pos " + position + " id " + id);
- String poiId = favDialog.adapter.getItemStringId(position);
+ String poiId = null;
+ if (favDialog != null) {
+ poiId = favDialog.adapter.getItemStringId(position);
+ } else if (searchResultsDialog != null) {
+ poiId = searchResultsDialog.adapter.getItemStringId(position);
+ }
Log.i(TAG, "POI " + poiId + " selected");
@@ -1146,8 +1172,14 @@ public class MapActivity extends ToastHelperActivity implements MapViewConstants
mapController.setZoom(20);
mapController.setCenter(poi.point);
- favDialog.dismiss();
- favDialog = null;
+ if (favDialog != null) {
+ favDialog.dismiss();
+ favDialog = null;
+ } else if (searchResultsDialog != null) {
+ searchResultsDialog.dismiss();
+ searchResultsDialog = null;
+ }
+
}
}
} else {
diff --git a/src/net/cbaines/suma/POIArrayAdapter.java b/src/net/cbaines/suma/POIArrayAdapter.java
index f9b5271..028f659 100644
--- a/src/net/cbaines/suma/POIArrayAdapter.java
+++ b/src/net/cbaines/suma/POIArrayAdapter.java
@@ -22,6 +22,7 @@ package net.cbaines.suma;
import java.util.List;
import android.content.Context;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
@@ -74,6 +75,7 @@ public class POIArrayAdapter extends BaseAdapter {
}
public String getItemStringId(int position) {
+ Log.v("POIArrayAdapter", POIs.get(position).toString());
return ((POI) POIs.get(position)).id;
}
} \ No newline at end of file
diff --git a/src/net/cbaines/suma/SearchActivity.java b/src/net/cbaines/suma/SearchResultsActivity.java
index 850996a..503c876 100644
--- a/src/net/cbaines/suma/SearchActivity.java
+++ b/src/net/cbaines/suma/SearchResultsActivity.java
@@ -52,7 +52,7 @@ import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
-public class SearchActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Runnable, TextWatcher,
+public class SearchResultsActivity extends OrmLiteBaseActivity<DatabaseHelper> implements Runnable, TextWatcher,
OnItemClickListener, LocationListener, OnItemLongClickListener {
final static String TAG = "FindActivity";