Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/data/NextGenDB.java
| Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | public class NextGenDB extends SQLiteOpenHelper{ | ||||
| * double latTo = bb.getLatNorthE6() / 1E6; | * double latTo = bb.getLatNorthE6() / 1E6; | ||||
| * double lngFrom = bb.getLonWestE6() / 1E6; | * double lngFrom = bb.getLonWestE6() / 1E6; | ||||
| * double lngTo = bb.getLonEastE6() / 1E6; | * double lngTo = bb.getLonEastE6() / 1E6; | ||||
| */ | */ | ||||
| public synchronized Stop[] queryAllInsideMapView(double minLat, double maxLat, double minLng, double maxLng) { | public synchronized Stop[] queryAllInsideMapView(double minLat, double maxLat, double minLng, double maxLng) { | ||||
| Stop[] stops = new Stop[0]; | Stop[] stops = new Stop[0]; | ||||
| SQLiteDatabase db = this.getReadableDatabase(); | SQLiteDatabase db = this.getReadableDatabase(); | ||||
| Cursor result; | //Cursor result=null; | ||||
| int count; | int count; | ||||
| // coordinates must be strings in the where condition | // coordinates must be strings in the where condition | ||||
| String minLatRaw = String.valueOf(minLat); | String minLatRaw = String.valueOf(minLat); | ||||
| String maxLatRaw = String.valueOf(maxLat); | String maxLatRaw = String.valueOf(maxLat); | ||||
| String minLngRaw = String.valueOf(minLng); | String minLngRaw = String.valueOf(minLng); | ||||
| String maxLngRaw = String.valueOf(maxLng); | String maxLngRaw = String.valueOf(maxLng); | ||||
| if(db == null) { | if(db == null) { | ||||
| return stops; | return stops; | ||||
| } | } | ||||
| try { | try { | ||||
| result = db.query(StopsTable.TABLE_NAME, QUERY_COLUMN_stops_all, QUERY_WHERE_LAT_AND_LNG_IN_RANGE, | final Cursor result = db.query(StopsTable.TABLE_NAME, QUERY_COLUMN_stops_all, QUERY_WHERE_LAT_AND_LNG_IN_RANGE, | ||||
| new String[] {minLatRaw, maxLatRaw, minLngRaw, maxLngRaw}, | new String[] {minLatRaw, maxLatRaw, minLngRaw, maxLngRaw}, | ||||
| null, null, null); | null, null, null); | ||||
| stops = getStopsFromCursorAllFields(result); | stops = getStopsFromCursorAllFields(result); | ||||
| result.close(); | |||||
| } catch(SQLiteException e) { | } catch(SQLiteException e) { | ||||
| Log.e(DEBUG_TAG, "SQLiteException occurred"); | Log.e(DEBUG_TAG, "SQLiteException occurred"); | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| return stops; | return stops; | ||||
| } | }finally { | ||||
| result.close(); | |||||
| db.close(); | db.close(); | ||||
| } | |||||
| return stops; | return stops; | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the list of stop in the query, with all the possible fields {NextGenDB.QUERY_COLUMN_stops_all} | * Get the list of stop in the query, with all the possible fields {NextGenDB.QUERY_COLUMN_stops_all} | ||||
| * @param result cursor from query | * @param result cursor from query | ||||
| * @return an Array of the stops found in the query | * @return an Array of the stops found in the query | ||||
| ▲ Show 20 Lines • Show All 161 Lines • Show Last 20 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