Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/middleware/StopsDB.java
Show All 36 Lines | |||||
import it.reyboz.bustorino.backend.StopsDBInterface; | import it.reyboz.bustorino.backend.StopsDBInterface; | ||||
public class StopsDB extends SQLiteAssetHelper implements StopsDBInterface { | public class StopsDB extends SQLiteAssetHelper implements StopsDBInterface { | ||||
private static String QUERY_TABLE_stops = "stops"; | private static String QUERY_TABLE_stops = "stops"; | ||||
private static String QUERY_WHERE_ID = "ID = ?"; | private static String QUERY_WHERE_ID = "ID = ?"; | ||||
private static String QUERY_WHERE_LAT_AND_LNG_IN_RANGE = "lat >= ? AND lat <= ? AND lon >= ? AND lon <= ?"; | private static String QUERY_WHERE_LAT_AND_LNG_IN_RANGE = "lat >= ? AND lat <= ? AND lon >= ? AND lon <= ?"; | ||||
private static String[] QUERY_COLUMN_name = {"name"}; | private static String[] QUERY_COLUMN_name = {"name"}; | ||||
private static String[] QUERY_COLUMN_location = {"location"}; | private static final String[] QUERY_COLUMN_location = {"location"}; | ||||
private static String[] QUERY_COLUMN_route = {"route"}; | private static final String[] QUERY_COLUMN_route = {"route"}; | ||||
private static String[] QUERY_COLUMN_everything = {"name", "location", "type", "lat", "lon"}; | private static final String[] QUERY_COLUMN_everything = {"name", "location", "type", "lat", "lon"}; | ||||
private static String[] QUERY_COLUMN_everything_and_ID = {"ID", "name", "location", "type", "lat", "lon"}; | private static final String[] QUERY_COLUMN_everything_and_ID = {"ID", "name", "location", "type", "lat", "lon"}; | ||||
private static String DB_NAME = "stops.sqlite"; | private static String DB_NAME = "stops.sqlite"; | ||||
private static int DB_VERSION = 1; | private static int DB_VERSION = 1; | ||||
private SQLiteDatabase db; | private SQLiteDatabase db; | ||||
private AtomicInteger openCounter = new AtomicInteger(); | private AtomicInteger openCounter = new AtomicInteger(); | ||||
public StopsDB(Context context) { | public StopsDB(Context context) { | ||||
super(context, DB_NAME, null, DB_VERSION); | super(context, DB_NAME, null, DB_VERSION); | ||||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | public Stop[] queryAllInsideMapView(double minLat, double maxLat, double minLng, double maxLng) { | ||||
stopID = result.getString(colID); | stopID = result.getString(colID); | ||||
type = routeTypeFromSymbol(result.getString(colType)); | type = routeTypeFromSymbol(result.getString(colType)); | ||||
String locationWhichSometimesIsAnEmptyString = result.getString(colLocation); | String locationWhichSometimesIsAnEmptyString = result.getString(colLocation); | ||||
if (locationWhichSometimesIsAnEmptyString.length() <= 0) { | if (locationWhichSometimesIsAnEmptyString.length() <= 0) { | ||||
locationWhichSometimesIsAnEmptyString = null; | locationWhichSometimesIsAnEmptyString = null; | ||||
} | } | ||||
stops[i++] = new Stop(stopID, result.getString(colName), null, locationWhichSometimesIsAnEmptyString, type, getRoutesByStop(stopID), result.getDouble(colLat), result.getDouble(colLon)); | stops[i++] = new Stop(stopID, result.getString(colName), null, | ||||
locationWhichSometimesIsAnEmptyString, type, getRoutesByStop(stopID), | |||||
result.getDouble(colLat), result.getDouble(colLon)); | |||||
} | } | ||||
} catch(SQLiteException e) { | } catch(SQLiteException e) { | ||||
// TODO: put a warning in the log | // TODO: put a warning in the log | ||||
return stops; | return stops; | ||||
} | } | ||||
result.close(); | result.close(); | ||||
Show All 22 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register