aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-28 19:09:23 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-28 19:09:23 +0000
commit0b5aefbe0ff01638dd264222c5368ad02a0fe1ee (patch)
tree2e6fdbd38ce7d97b757dcf365fe72aac7a163ddb /src
parented7638698d439d75ada5120121a137f8e6f09bf8 (diff)
downloadsouthamptonuniversitymap-0b5aefbe0ff01638dd264222c5368ad02a0fe1ee.tar
southamptonuniversitymap-0b5aefbe0ff01638dd264222c5368ad02a0fe1ee.tar.gz
Fixed two bugs relating to the query on the database not being ordered?, and implemented a new preference option.
Diffstat (limited to 'src')
-rw-r--r--src/net/cbaines/suma/BusRoute.java74
-rw-r--r--src/net/cbaines/suma/BusStopActivity.java10
-rw-r--r--src/net/cbaines/suma/DataManager.java22
-rw-r--r--src/net/cbaines/suma/DatabaseHelper.java8
-rw-r--r--src/net/cbaines/suma/MapActivity.java2
-rw-r--r--src/net/cbaines/suma/POIView.java28
-rw-r--r--src/net/cbaines/suma/Preferences.java3
-rw-r--r--src/net/cbaines/suma/PreferencesActivity.java3
-rw-r--r--src/net/cbaines/suma/RouteStop.java (renamed from src/net/cbaines/suma/RouteStops.java)15
9 files changed, 96 insertions, 69 deletions
diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java
index b4dd603..ff80c66 100644
--- a/src/net/cbaines/suma/BusRoute.java
+++ b/src/net/cbaines/suma/BusRoute.java
@@ -22,6 +22,7 @@ package net.cbaines.suma;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -64,8 +65,7 @@ public class BusRoute {
String label;
/**
- * The direction the bus is travelling if it is moving through the route and
- * sequence is increasing.
+ * The direction the bus is travelling if it is moving through the route and sequence is increasing.
* <ul>
* <li>U1 = A</li>
* <li>U2 = B</li>
@@ -76,8 +76,7 @@ public class BusRoute {
String forwardDirection;
/**
- * The direction the bus is travelling if it is moving through the route and
- * sequence is decreasing.
+ * The direction the bus is travelling if it is moving through the route and sequence is decreasing.
* <ul>
* <li>U1 = C</li>
* <li>U2 = C</li>
@@ -93,8 +92,7 @@ public class BusRoute {
BusRoute() {
}
- public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection,
- boolean uniLink) {
+ public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection, boolean uniLink) {
this.id = id.intValue();
this.code = code;
this.label = label;
@@ -153,18 +151,19 @@ public class BusRoute {
DatabaseHelper helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
try {
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao();
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+ QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
- List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ Collections.sort(routeStopsFound);
- ArrayList<Integer> stopIndexs = new ArrayList<Integer>();
+ Set<Integer> stopIndexs = new HashSet<Integer>();
- for (RouteStops routeStop : routeStopsFound) {
+ for (RouteStop routeStop : routeStopsFound) {
if (routeStop.busStop.id.equals(busStop.id)) {
stopIndexs.add(routeStop.sequence - 1);
}
@@ -241,18 +240,19 @@ public class BusRoute {
}
try {
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao();
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+ QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
- List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ Collections.sort(routeStopsFound);
int stopIndex = -1;
- for (RouteStops routeStop : routeStopsFound) {
+ for (RouteStop routeStop : routeStopsFound) {
if (routeStop.busStop.id.equals(busStop.id)) {
if (stopIndex == -1) {
stopIndex = routeStop.sequence - 1;
@@ -377,8 +377,9 @@ public class BusRoute {
}
if (moveAmount > 0) {
- Log.v(TAG, "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/"
- + routeStopsFound.size() + ")");
+ Log.v(TAG,
+ "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/"
+ + routeStopsFound.size() + ")");
int stopWanted = stopIndex + moveAmount;
if ((stopWanted + 1) > routeStopsFound.size()) {
Log.v(TAG, "Off the end of the route");
@@ -401,9 +402,8 @@ public class BusRoute {
Log.v(TAG, "stopWanted " + stopWanted);
busStopDao.refresh(routeStopsFound.get(stopWanted).busStop);
- Log.v(TAG,
- "Moving backwards " + moveAmount + " stops from " + busStop + " to "
- + routeStopsFound.get(stopWanted).busStop + " in route " + this);
+ Log.v(TAG, "Moving backwards " + moveAmount + " stops from " + busStop + " to "
+ + routeStopsFound.get(stopWanted).busStop + " in route " + this);
return routeStopsFound.get(stopWanted).busStop;
}
@@ -442,14 +442,15 @@ public class BusRoute {
try {
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao();
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+ QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
- List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ Collections.sort(routeStopsFound);
int startStopSeq = -1;
int endStopSeq = -1;
@@ -500,7 +501,7 @@ public class BusRoute {
Log.e(TAG, "Error, unrecognised route " + id);
}
- for (RouteStops routeStop : routeStopsFound) {
+ for (RouteStop routeStop : routeStopsFound) {
if (routeStop.sequence >= startStopSeq && routeStop.sequence <= endStopSeq) {
busStopDao.refresh(routeStop.busStop);
busStops.add(routeStop.busStop);
@@ -525,16 +526,17 @@ public class BusRoute {
try {
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao();
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
- QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
- routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, this.id);
- PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+ QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, this.id);
+ PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
- List<RouteStops> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ List<RouteStop> routeStopsFound = routeStopsDao.query(routeStopsPreparedQuery);
+ Collections.sort(routeStopsFound);
- for (RouteStops routeStop : routeStopsFound) {
+ for (RouteStop routeStop : routeStopsFound) {
busStopDao.refresh(routeStop.busStop);
busStops.add(routeStop.busStop);
}
diff --git a/src/net/cbaines/suma/BusStopActivity.java b/src/net/cbaines/suma/BusStopActivity.java
index 55a0bd6..8bded40 100644
--- a/src/net/cbaines/suma/BusStopActivity.java
+++ b/src/net/cbaines/suma/BusStopActivity.java
@@ -153,15 +153,15 @@ public class BusStopActivity extends OrmLiteBaseActivity<DatabaseHelper> impleme
busStop = busStopDao.queryForId(busStopID);
Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao();
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao();
for (BusRoute route : busRouteDao) {
- QueryBuilder<RouteStops, Integer> queryBuilder = routeStopsDao.queryBuilder();
+ QueryBuilder<RouteStop, Integer> queryBuilder = routeStopsDao.queryBuilder();
- queryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and()
- .eq(RouteStops.STOP_ID_FIELD_NAME, busStopID);
+ queryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, route.id).and()
+ .eq(RouteStop.STOP_ID_FIELD_NAME, busStopID);
queryBuilder.setCountOf(true);
- PreparedQuery<RouteStops> preparedQuery = queryBuilder.prepare();
+ PreparedQuery<RouteStop> preparedQuery = queryBuilder.prepare();
long count = routeStopsDao.countOf(preparedQuery);
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index 3a550a7..5e8b195 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -214,11 +214,11 @@ public class DataManager {
Dao<BusStop, String> busStopDao = helper.getBusStopDao();
Dao<BusRoute, Integer> busRouteDao = helper.getBusRouteDao();
- Dao<RouteStops, Integer> routeStopsDao = helper.getRouteStopsDao();
+ Dao<RouteStop, Integer> routeStopsDao = helper.getRouteStopsDao();
TableUtils.clearTable(helper.getConnectionSource(), BusStop.class);
TableUtils.clearTable(helper.getConnectionSource(), BusRoute.class);
- TableUtils.clearTable(helper.getConnectionSource(), RouteStops.class);
+ TableUtils.clearTable(helper.getConnectionSource(), RouteStop.class);
Log.i(TAG, "Loading busstops from csv");
@@ -340,7 +340,7 @@ public class DataManager {
int sequence = Integer.parseInt(dataBits[1]);
Log.i(TAG, "Creating RouteStop " + busStop.id + " " + busRoute.code + " " + sequence);
- routeStopsDao.create(new RouteStops(busStop, busRoute, sequence));
+ routeStopsDao.create(new RouteStop(busStop, busRoute, sequence));
if (busRoute.id == 326) { // U1
busStop.routes = (byte) (busStop.routes | 1);
@@ -457,7 +457,7 @@ public class DataManager {
helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
if (busRouteDao == null)
busRouteDao = helper.getBusRouteDao();
- Dao<RouteStops, Integer> routeStopsDao = null;
+ Dao<RouteStop, Integer> routeStopsDao = null;
if (routeStopsDao == null)
routeStopsDao = helper.getRouteStopsDao();
if (busDao == null)
@@ -568,12 +568,12 @@ public class DataManager {
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();
+ QueryBuilder<RouteStop, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStop.ROUTE_ID_FIELD_NAME, route.id).and()
+ .eq(RouteStop.STOP_ID_FIELD_NAME, destStop.id);
+ PreparedQuery<RouteStop> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
- List<RouteStops> routeStops = routeStopsDao.query(routeStopsPreparedQuery);
+ List<RouteStop> routeStops = routeStopsDao.query(routeStopsPreparedQuery);
if (routeStops.size() > 0) {
Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route "
+ route.code);
@@ -855,7 +855,7 @@ public class DataManager {
public static void routeMovementTest(Context context) throws SQLException {
- Dao<RouteStops, Integer> routeStopsDao = null;
+ Dao<RouteStop, Integer> routeStopsDao = null;
if (helper == null)
helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
@@ -870,7 +870,7 @@ public class DataManager {
if (!busRoute.code.startsWith("U") || busRoute.code.equals("U9")) {
continue;
}
- List<RouteStops> routeStops = routeStopsDao.queryForEq(RouteStops.ROUTE_ID_FIELD_NAME, busRoute.id);
+ List<RouteStop> routeStops = routeStopsDao.queryForEq(RouteStop.ROUTE_ID_FIELD_NAME, busRoute.id);
ArrayList<String> directions = new ArrayList<String>();
if (busRoute.forwardDirection != null) {
diff --git a/src/net/cbaines/suma/DatabaseHelper.java b/src/net/cbaines/suma/DatabaseHelper.java
index 13f4957..facfe85 100644
--- a/src/net/cbaines/suma/DatabaseHelper.java
+++ b/src/net/cbaines/suma/DatabaseHelper.java
@@ -48,7 +48,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private Dao<Building, String> buildingDao = null;
private Dao<BusStop, String> busStopDao = null;
private Dao<BusRoute, Integer> busRouteDao = null;
- private Dao<RouteStops, Integer> routeStopsDao = null;
+ private Dao<RouteStop, Integer> routeStopsDao = null;
private Dao<Site, String> siteDao = null;
private Dao<Bus, Integer> busDao = null;
@@ -67,7 +67,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.createTable(connectionSource, Building.class);
TableUtils.createTable(connectionSource, BusStop.class);
TableUtils.createTable(connectionSource, BusRoute.class);
- TableUtils.createTable(connectionSource, RouteStops.class);
+ TableUtils.createTable(connectionSource, RouteStop.class);
TableUtils.createTable(connectionSource, Site.class);
TableUtils.createTable(connectionSource, Bus.class);
} catch (SQLException e) {
@@ -125,9 +125,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
* Returns the Database Access Object (DAO) for our SimpleData class. It
* will create it or just give the cached value.
*/
- public Dao<RouteStops, Integer> getRouteStopsDao() throws SQLException {
+ public Dao<RouteStop, Integer> getRouteStopsDao() throws SQLException {
if (routeStopsDao == null) {
- routeStopsDao = getDao(RouteStops.class);
+ routeStopsDao = getDao(RouteStop.class);
}
return routeStopsDao;
}
diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java
index 8f555da..e2b9d66 100644
--- a/src/net/cbaines/suma/MapActivity.java
+++ b/src/net/cbaines/suma/MapActivity.java
@@ -389,7 +389,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();
diff --git a/src/net/cbaines/suma/POIView.java b/src/net/cbaines/suma/POIView.java
index b27b4f3..95c571c 100644
--- a/src/net/cbaines/suma/POIView.java
+++ b/src/net/cbaines/suma/POIView.java
@@ -20,6 +20,7 @@
package net.cbaines.suma;
import android.content.Context;
+import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
@@ -27,7 +28,7 @@ import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
-public class POIView extends LinearLayout {
+public class POIView extends LinearLayout implements Preferences {
private final static String TAG = "POIView";
@@ -37,6 +38,8 @@ public class POIView extends LinearLayout {
private LayoutParams textLayoutParams;
+ private boolean identifiersEnabled;
+
final int width;
public POIView(Context context, POI poi) {
@@ -46,6 +49,9 @@ public class POIView extends LinearLayout {
public POIView(Context context, POI poi, int distInM) {
super(context);
+ identifiersEnabled = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SHOW_IDENTIFIERS,
+ SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT);
+
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
width = display.getWidth();
// int height = display.getHeight();
@@ -85,14 +91,22 @@ public class POIView extends LinearLayout {
Building building = (Building) poi;
// Log.i(TAG, "Its a building of name " + building.name);
- name.setText(building.name + " (" + building.id + ")");
+ if (identifiersEnabled) {
+ name.setText(building.name + " (" + building.id + ")");
+ } else {
+ name.setText(building.name);
+ }
} else if (poi.type == POI.BUS_STOP) {
BusStop busStop = (BusStop) poi;
// Log.i(TAG, "Its a bus stop of description " +
// busStop.description);
- name.setText(busStop.description + " (" + busStop.id + ")");
+ if (identifiersEnabled) {
+ name.setText(busStop.description + " (" + busStop.id + ")");
+ } else {
+ name.setText(busStop.description);
+ }
routes.setRoutes(busStop.routes);
@@ -100,8 +114,11 @@ public class POIView extends LinearLayout {
Site site = (Site) poi;
// Log.i(TAG, "Its a site of name " + site.name);
-
- name.setText(site.name + " (" + site.id + ")");
+ if (identifiersEnabled) {
+ name.setText(site.name + " (" + site.id + ")");
+ } else {
+ name.setText(site.name);
+ }
} else {
Log.w(TAG, "Cant identify " + poi.type);
@@ -121,5 +138,4 @@ public class POIView extends LinearLayout {
// Log.w("POIView", "No dist avalible for S" + poi.id);
}
}
-
} \ No newline at end of file
diff --git a/src/net/cbaines/suma/Preferences.java b/src/net/cbaines/suma/Preferences.java
index ff8f366..0508251 100644
--- a/src/net/cbaines/suma/Preferences.java
+++ b/src/net/cbaines/suma/Preferences.java
@@ -11,5 +11,8 @@ public interface Preferences {
static final String NON_UNI_LINK_BUS_STOPS_OVERLAY = "nonUniLinkBusStops";
static final boolean NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT = false;
+ static final String SHOW_IDENTIFIERS = "showIdentifiers";
+ static final boolean SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT = false;
+
static final String FAVOURITES_PREFERENCES = "favourites";
}
diff --git a/src/net/cbaines/suma/PreferencesActivity.java b/src/net/cbaines/suma/PreferencesActivity.java
index 39e6bb2..bab72bf 100644
--- a/src/net/cbaines/suma/PreferencesActivity.java
+++ b/src/net/cbaines/suma/PreferencesActivity.java
@@ -45,6 +45,9 @@ public class PreferencesActivity extends PreferenceActivity implements Preferenc
if (!sharedPrefs.contains(NON_UNI_LINK_BUS_STOPS_OVERLAY)) {
editor.putBoolean(NON_UNI_LINK_BUS_STOPS_OVERLAY, NON_UNI_LINK_BUS_STOP_OVERLAY_ENABLED_BY_DEFAULT);
}
+ if (!sharedPrefs.contains(SHOW_IDENTIFIERS)) {
+ editor.putBoolean(SHOW_IDENTIFIERS, SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT);
+ }
editor.commit();
addPreferencesFromResource(R.xml.preferences);
diff --git a/src/net/cbaines/suma/RouteStops.java b/src/net/cbaines/suma/RouteStop.java
index 2f6c00a..a19f4fa 100644
--- a/src/net/cbaines/suma/RouteStops.java
+++ b/src/net/cbaines/suma/RouteStop.java
@@ -23,15 +23,14 @@ import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable(tableName = "routestops")
-public class RouteStops {
+public class RouteStop implements Comparable<RouteStop> {
public final static String STOP_ID_FIELD_NAME = "stop_id";
public final static String ROUTE_ID_FIELD_NAME = "route_id";
public final static String SEQUENCE_ID_FIELD_NAME = "sequence";
/**
- * This id is generated by the database and set on the object when it is
- * passed to the create method. An id is needed in case we need to update or
- * delete this object in the future.
+ * This id is generated by the database and set on the object when it is passed to the create method. An id is needed in case
+ * we need to update or delete this object in the future.
*/
@DatabaseField(generatedId = true)
int id;
@@ -49,12 +48,16 @@ public class RouteStops {
@DatabaseField(foreign = true, columnName = ROUTE_ID_FIELD_NAME, indexName = "routestops_routestop_idx")
BusRoute busRoute;
- RouteStops() {
+ RouteStop() {
}
- public RouteStops(BusStop stop, BusRoute route, int sequence) {
+ public RouteStop(BusStop stop, BusRoute route, int sequence) {
this.busStop = stop;
this.busRoute = route;
this.sequence = sequence;
}
+
+ public int compareTo(RouteStop routeStop) {
+ return this.sequence - routeStop.sequence;
+ }
}