|
@@ -116,9 +116,7 @@ public class DataHelper {
|
116
|
116
|
} while (cursor.moveToNext());
|
117
|
117
|
}
|
118
|
118
|
|
119
|
|
- if (cursor != null && !cursor.isClosed()) {
|
120
|
|
- cursor.close();
|
121
|
|
- }
|
|
119
|
+ closeCursor(cursor);
|
122
|
120
|
|
123
|
121
|
return results;
|
124
|
122
|
}
|
|
@@ -149,9 +147,7 @@ public class DataHelper {
|
149
|
147
|
} while (cursor.moveToNext());
|
150
|
148
|
}
|
151
|
149
|
|
152
|
|
- if (cursor != null && !cursor.isClosed()) {
|
153
|
|
- cursor.close();
|
154
|
|
- }
|
|
150
|
+ closeCursor(cursor);
|
155
|
151
|
|
156
|
152
|
return results;
|
157
|
153
|
}
|
|
@@ -230,9 +226,7 @@ public class DataHelper {
|
230
|
226
|
} while (cursor.moveToNext());
|
231
|
227
|
}
|
232
|
228
|
|
233
|
|
- if (cursor != null && !cursor.isClosed()) {
|
234
|
|
- cursor.close();
|
235
|
|
- }
|
|
229
|
+ closeCursor(cursor);
|
236
|
230
|
|
237
|
231
|
final List<JourneyStep> ordered = new LinkedList<JourneyStep>();
|
238
|
232
|
|
|
@@ -257,17 +251,25 @@ public class DataHelper {
|
257
|
251
|
Location.distanceBetween(lat, lon, cursor.getDouble(2), cursor.getDouble(3), res);
|
258
|
252
|
|
259
|
253
|
if (res[0] <= 500) {
|
260
|
|
- return new Place(cursor.getLong(0), cursor.getString(1),
|
|
254
|
+ final Place place = new Place(cursor.getLong(0), cursor.getString(1),
|
261
|
255
|
cursor.getDouble(2), cursor.getDouble(3));
|
|
256
|
+
|
|
257
|
+ closeCursor(cursor);
|
|
258
|
+
|
|
259
|
+ return place;
|
262
|
260
|
}
|
263
|
261
|
} while (cursor.moveToNext());
|
264
|
262
|
}
|
265
|
263
|
|
|
264
|
+ closeCursor(cursor);
|
|
265
|
+
|
|
266
|
+ return null;
|
|
267
|
+ }
|
|
268
|
+
|
|
269
|
+ private static void closeCursor(final Cursor cursor) {
|
266
|
270
|
if (cursor != null && !cursor.isClosed()) {
|
267
|
271
|
cursor.close();
|
268
|
272
|
}
|
269
|
|
-
|
270
|
|
- return null;
|
271
|
273
|
}
|
272
|
274
|
|
273
|
275
|
private static class OpenHelper extends SQLiteOpenHelper {
|