aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-18 21:14:17 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-18 21:14:17 +0000
commit4ee5e20a86f34961ffaf2081f2602e1486de6f92 (patch)
tree57ef79ee93ca5d38dda2fb86aac275c1586c54a5
parentb374a50fb6f3bd0866bc1f75f7592abb0a6b8cc1 (diff)
downloadsouthamptonuniversitymap-4ee5e20a86f34961ffaf2081f2602e1486de6f92.tar
southamptonuniversitymap-4ee5e20a86f34961ffaf2081f2602e1486de6f92.tar.gz
More bug fixes, working non uni link bus times, just need to get the non uni link bus stops working :)
-rw-r--r--res/xml/preferences.xml2
-rw-r--r--src/net/cbaines/suma/BuildingActivity.java84
-rw-r--r--src/net/cbaines/suma/BuildingNumOverlay.java34
-rw-r--r--src/net/cbaines/suma/DataManager.java30
-rw-r--r--src/net/cbaines/suma/MapActivity.java33
-rw-r--r--src/net/cbaines/suma/Stop.java7
-rw-r--r--src/net/cbaines/suma/StopView.java16
-rw-r--r--src/net/cbaines/suma/TimetableAdapter.java1
8 files changed, 70 insertions, 137 deletions
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index f4cdd9f..4a12e1c 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -28,7 +28,7 @@
android:orderingFromXml="true"
android:title="@string/preferences_catagory_data" >
<CheckBoxPreference
- android:key="nonUniLinkBusStop"
+ android:key="nonUniLinkBusStops"
android:summaryOff="@string/preferences_non_uni_link_disabled"
android:summaryOn="@string/preferences_non_uni_link_enabled"
android:title="@string/preferences_non_uni_link" />
diff --git a/src/net/cbaines/suma/BuildingActivity.java b/src/net/cbaines/suma/BuildingActivity.java
deleted file mode 100644
index ca605c8..0000000
--- a/src/net/cbaines/suma/BuildingActivity.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-
- * Southampton University Map App
- * Copyright (C) 2011 Christopher Baines
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package net.cbaines.suma;
-
-import java.io.InputStream;
-import java.util.HashSet;
-
-import android.content.Context;
-import android.os.Bundle;
-
-import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
-
-public class BuildingActivity extends OrmLiteBaseActivity<DatabaseHelper> {
-
- final static String TAG = "BusTimeActivity";
-
- private boolean dataChanged;
-
- private Context instance;
-
- private HashSet<BusRoute> routes = new HashSet<BusRoute>();
-
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.bustimes);
-
- final DatabaseHelper helper = getHelper();
-
- // create an empty model
- // Model model = ModelFactory.createDefaultModel();
-
- // use the FileManager to find the input file
- InputStream in = getResources().openRawResource(R.raw.u9);
- if (in == null) {
- throw new IllegalArgumentException("File not found");
- }
-
- // read the RDF/XML file
- // model.read(in, null);
-
- instance = this;
-
- }
-
- public void onResume() {
- super.onResume();
-
- }
-
- public void onPause() {
-
- super.onPause();
- }
-
- public void finish() {
- setResult(RESULT_OK, getIntent());
-
- super.finish();
- }
-
- @Override
- public Object onRetainNonConfigurationInstance() {
- return null;
- }
-
-}
diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java
index 9825616..33b5efc 100644
--- a/src/net/cbaines/suma/BuildingNumOverlay.java
+++ b/src/net/cbaines/suma/BuildingNumOverlay.java
@@ -29,7 +29,6 @@ import org.osmdroid.views.MapView;
import org.osmdroid.views.MapView.Projection;
import org.osmdroid.views.overlay.Overlay;
-import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@@ -92,25 +91,29 @@ public class BuildingNumOverlay extends Overlay {
/**
* Draw a marker on each of our items. populate() must have been called first.<br/>
* <br/>
- * The marker will be drawn twice for each Item in the Overlay--once in the shadow phase, skewed and darkened, then again in the non-shadow phase. The
- * bottom-center of the marker will be aligned with the geographical coordinates of the Item.<br/>
+ * The marker will be drawn twice for each Item in the Overlay--once in the shadow phase, skewed and darkened, then
+ * again in the non-shadow phase. The bottom-center of the marker will be aligned with the geographical coordinates
+ * of the Item.<br/>
* <br/>
- * The order of drawing may be changed by overriding the getIndexToDraw(int) method. An item may provide an alternate marker via its
- * OverlayItem.getMarker(int) method. If that method returns null, the default marker is used.<br/>
+ * The order of drawing may be changed by overriding the getIndexToDraw(int) method. An item may provide an
+ * alternate marker via its OverlayItem.getMarker(int) method. If that method returns null, the default marker is
+ * used.<br/>
* <br/>
* The focused item is always drawn last, which puts it visually on top of the other items.<br/>
*
* @param canvas
- * the Canvas upon which to draw. Note that this may already have a transformation applied, so be sure to leave it the way you found it
+ * the Canvas upon which to draw. Note that this may already have a transformation applied, so be sure to
+ * leave it the way you found it
* @param mapView
- * the MapView that requested the draw. Use MapView.getProjection() to convert between on-screen pixels and latitude/longitude pairs
+ * the MapView that requested the draw. Use MapView.getProjection() to convert between on-screen pixels
+ * and latitude/longitude pairs
* @param shadow
* if true, draw the shadow layer. If false, draw the overlay contents.
*/
@Override
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
- if (shadow) {
+ if (shadow || !isEnabled()) {
return;
}
@@ -181,7 +184,8 @@ public class BuildingNumOverlay extends Overlay {
@Override
public boolean onSingleTapUp(final MotionEvent event, final MapView mapView) {
- Log.v(TAG, "Pointer count for onSingleTapUp is " + event.getPointerCount() + " " + event.getAction() + " " + event.describeContents());
+ Log.v(TAG, "Pointer count for onSingleTapUp is " + event.getPointerCount() + " " + event.getAction() + " "
+ + event.describeContents());
if (event.getPointerCount() != 1) {
Log.v(TAG, "Pointer count for onSingleTapUp not 1, ignoring");
return false;
@@ -199,7 +203,8 @@ public class BuildingNumOverlay extends Overlay {
Log.i(TAG, "building Pressed " + building.id);
if (context.activityToast == null) {
- context.activityToast = Toast.makeText(context, building.name + " (" + building.id + ")", Toast.LENGTH_SHORT);
+ context.activityToast = Toast.makeText(context, building.name + " (" + building.id + ")",
+ Toast.LENGTH_SHORT);
} else {
context.activityToast.setDuration(Toast.LENGTH_SHORT);
context.activityToast.setText(building.name + " (" + building.id + ")");
@@ -218,7 +223,8 @@ public class BuildingNumOverlay extends Overlay {
@Override
public boolean onLongPress(final MotionEvent event, final MapView mapView) {
- Log.v(TAG, "Pointer count for onLongPress is " + event.getPointerCount() + " " + event.getAction() + " " + event.describeContents());
+ Log.v(TAG, "Pointer count for onLongPress is " + event.getPointerCount() + " " + event.getAction() + " "
+ + event.describeContents());
if (event.getPointerCount() != 1) {
Log.v(TAG, "Pointer count for onLongPress not 1, ignoring");
return false;
@@ -239,7 +245,8 @@ public class BuildingNumOverlay extends Overlay {
building.favourite = false;
if (context.activityToast == null) {
- context.activityToast = Toast.makeText(context, building.id + " removed from favourites", Toast.LENGTH_SHORT);
+ context.activityToast = Toast.makeText(context, building.id + " removed from favourites",
+ Toast.LENGTH_SHORT);
} else {
context.activityToast.setDuration(Toast.LENGTH_SHORT);
context.activityToast.setText(building.id + " removed from favourites");
@@ -248,7 +255,8 @@ public class BuildingNumOverlay extends Overlay {
} else {
if (context.activityToast == null) {
- context.activityToast = Toast.makeText(context, building.id + " made a favourite", Toast.LENGTH_SHORT);
+ context.activityToast = Toast.makeText(context, building.id + " made a favourite",
+ Toast.LENGTH_SHORT);
} else {
context.activityToast.setDuration(Toast.LENGTH_SHORT);
context.activityToast.setText(building.id + " made a favourite");
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index 196a7e2..140ddfa 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -561,19 +561,21 @@ public class DataManager {
Log.e(TAG, "Unknown end dest " + destString + " for route " + route.code);
}
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and()
- .eq(RouteStops.STOP_ID_FIELD_NAME, destStop.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
-
- List<RouteStops> routeStops = routeStopsDao.query(routeStopsPreparedQuery);
- if (routeStops.size() > 0) {
- Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route "
- + route.code);
- } else {
- Log.e(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route "
- + route.code);
- return null;
+ if (destStop != null) {
+
+ QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and()
+ .eq(RouteStops.STOP_ID_FIELD_NAME, destStop.id);
+ PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+
+ List<RouteStops> routeStops = routeStopsDao.query(routeStopsPreparedQuery);
+ if (routeStops.size() > 0) {
+ Log.i(TAG, "Found " + routeStops.size() + " 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);
+ }
}
Date now = new Date(System.currentTimeMillis());
@@ -653,10 +655,12 @@ public class DataManager {
JSONObject stopObj = stopsArray.getJSONObject(stopNum);
if (!keepNonUniLink && !stopObj.getString("name").startsWith("U")) {
+ Log.v(TAG, "Skipping non uni-link stop " + stopObj.getString("name"));
continue;
}
if (!keepUniLink && stopObj.getString("name").startsWith("U")) {
+ Log.v(TAG, "Skipping uni-link stop " + stopObj.getString("name"));
continue;
}
diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java
index 4d9eddc..c0a2aba 100644
--- a/src/net/cbaines/suma/MapActivity.java
+++ b/src/net/cbaines/suma/MapActivity.java
@@ -78,7 +78,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
* 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 = false;
+ private boolean useBundledDatabase = true;
private MapView mapView;
private MapController mapController;
@@ -444,15 +444,15 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
showUtilityOverlays();
- showUniLinkBusStopOverlays();
+ showUniLinkBusStopOverlay();
- showNonUniLinkBusStopOverlays();
+ showNonUniLinkBusStopOverlay();
if (activityPrefs.getBoolean(BUILDING_OVERLAYS + RESIDENTIAL_BUILDING_OVERLAY,
RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT)
|| activityPrefs.getBoolean(BUILDING_OVERLAYS + NON_RESIDENTIAL_BUILDING_OVERLAY,
NON_RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT)) {
- showBuildingOverlay();
+ showBuildingOverlays();
}
Log.i(TAG, "Begining to show the route overlays at " + (System.currentTimeMillis() - startTime));
@@ -662,7 +662,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}).start();
}
- private void showBuildingOverlay() {
+ private void showBuildingOverlays() {
new Thread(new Runnable() {
public void run() {
Log.i(TAG, "Begining showing building overlays at " + (System.currentTimeMillis() - startTime));
@@ -728,10 +728,10 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}
}
- residentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(RESIDENTIAL_BUILDING_OVERLAY,
- RESIDENTIAL_BUILDING_OVERLAY_ENABLED_BY_DEFAULT));
- nonResidentialBuildingOverlay.setEnabled(activityPrefs.getBoolean(RESIDENTIAL_BUILDING_OVERLAY,
- NON_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));
mapView.postInvalidate();
@@ -740,7 +740,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}).start();
}
- private void showUniLinkBusStopOverlays() {
+ private void showUniLinkBusStopOverlay() {
new Thread(new Runnable() {
public void run() {
Log.i(TAG, "Begining showing bus stop overlays at " + (System.currentTimeMillis() - startTime));
@@ -800,10 +800,11 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
}).start();
}
- private void showNonUniLinkBusStopOverlays() {
+ private void showNonUniLinkBusStopOverlay() {
new Thread(new Runnable() {
public void run() {
- Log.i(TAG, "Begining showing 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 OverlayRankComparator comparator = new OverlayRankComparator(getPreferences(0));
@@ -1198,9 +1199,9 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
} else if (key.equals(UNI_LINK_BUS_TIMES)) {
// Noting to do here atm
} else if (key.startsWith(BUS_STOP_OVERLAYS)) {
- showUniLinkBusStopOverlays();
- } else if (key.startsWith(NON_UNI_LINK_BUS_STOPS)) {
- showNonUniLinkBusStopOverlays();
+ showUniLinkBusStopOverlay();
+ } else if (key.equals(NON_UNI_LINK_BUS_STOPS)) {
+ showNonUniLinkBusStopOverlay();
} else if (key.startsWith(BUS_ROUTE_OVERLAYS)) {
try {
String routeName = key.substring(BUS_ROUTE_OVERLAYS.length(), key.length());
@@ -1214,7 +1215,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
e.printStackTrace();
}
} else if (key.startsWith(BUILDING_OVERLAYS)) {
- showBuildingOverlay();
+ showBuildingOverlays();
} else if (key.startsWith(SITE_OVERLAYS)) {
String siteName = key.substring(SITE_OVERLAYS.length(), key.length());
try {
diff --git a/src/net/cbaines/suma/Stop.java b/src/net/cbaines/suma/Stop.java
index c6bedf0..94fc908 100644
--- a/src/net/cbaines/suma/Stop.java
+++ b/src/net/cbaines/suma/Stop.java
@@ -22,7 +22,6 @@ package net.cbaines.suma;
import java.util.Date;
import android.text.format.DateUtils;
-import android.util.Log;
/**
* Stop represents a Bus stopping at a time at a BusStop.
@@ -90,7 +89,8 @@ public class Stop {
if (arivalTime.getTime() - System.currentTimeMillis() <= 60000) {
return "Due";
} else {
- return (String) DateUtils.getRelativeTimeSpanString(arivalTime.getTime(), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
+ return (String) DateUtils.getRelativeTimeSpanString(arivalTime.getTime(), System.currentTimeMillis(),
+ DateUtils.MINUTE_IN_MILLIS);
}
}
@@ -98,7 +98,8 @@ public class Stop {
if (arivalTime.getTime() - System.currentTimeMillis() <= 60000) {
return "Due";
} else {
- String time = (String) DateUtils.getRelativeTimeSpanString(arivalTime.getTime(), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
+ String time = (String) DateUtils.getRelativeTimeSpanString(arivalTime.getTime(),
+ System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
time = time.replace("in ", "");
time = time.replace(" minutes", "m");
time = time.replace(" minute", "m");
diff --git a/src/net/cbaines/suma/StopView.java b/src/net/cbaines/suma/StopView.java
index 011964d..08e5843 100644
--- a/src/net/cbaines/suma/StopView.java
+++ b/src/net/cbaines/suma/StopView.java
@@ -23,7 +23,6 @@ import java.sql.SQLException;
import java.text.DateFormat;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.View;
@@ -87,15 +86,19 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli
if (stop.bus.id != null) {
if (stop.live) {
- onClickMessage = "Bus " + stop.bus.toString() + " at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
+ onClickMessage = "Bus " + stop.bus.toString() + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
} else {
- onClickMessage = "Timetabled bus " + stop.bus.toString() + " at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
+ onClickMessage = "Timetabled bus " + stop.bus.toString() + " at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
}
} else {
if (stop.live) {
- onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
+ onClickMessage = "Unidentified bus (" + stop.bus.getName() + ") at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
} else {
- onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
+ onClickMessage = "Timetabled bus (" + stop.bus.getName() + ") at "
+ + DateFormat.getTimeInstance(DateFormat.SHORT).format(stop.arivalTime);
}
}
} catch (SQLException e) {
@@ -133,7 +136,8 @@ public class StopView extends LinearLayout implements OnClickListener, OnLongCli
((Activity) context).startActivityForResult(i, 0);
} else {
if (context.activityToast == null) {
- context.activityToast = Toast.makeText(context, "Arival prediction not avalible for timetabled buses", Toast.LENGTH_SHORT);
+ context.activityToast = Toast.makeText(context,
+ "Arival prediction not avalible for timetabled buses", Toast.LENGTH_SHORT);
} else {
context.activityToast.setText("Arival prediction not avalible for timetabled buses");
context.activityToast.setDuration(Toast.LENGTH_SHORT);
diff --git a/src/net/cbaines/suma/TimetableAdapter.java b/src/net/cbaines/suma/TimetableAdapter.java
index ae4407f..9ec7a72 100644
--- a/src/net/cbaines/suma/TimetableAdapter.java
+++ b/src/net/cbaines/suma/TimetableAdapter.java
@@ -19,7 +19,6 @@
package net.cbaines.suma;
-import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;