aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/DataStore.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-03-06 00:26:58 +0100
committerSamuel Tardieu <sam@rfc1149.net>2014-03-06 00:26:58 +0100
commitf5f53b5ae581931e514e941ad857e4b392bfe630 (patch)
tree520e73495a9a82b63b1253d8e1a267a313947e54 /main/src/cgeo/geocaching/DataStore.java
parentc88e8e4d3d5269f0c7caf00202549f45f2e8c7ac (diff)
downloadcgeo-f5f53b5ae581931e514e941ad857e4b392bfe630.zip
cgeo-f5f53b5ae581931e514e941ad857e4b392bfe630.tar.gz
cgeo-f5f53b5ae581931e514e941ad857e4b392bfe630.tar.bz2
refactoring: factor out common code
Diffstat (limited to 'main/src/cgeo/geocaching/DataStore.java')
-rw-r--r--main/src/cgeo/geocaching/DataStore.java26
1 files changed, 7 insertions, 19 deletions
diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java
index a7e3745..e219e1b 100644
--- a/main/src/cgeo/geocaching/DataStore.java
+++ b/main/src/cgeo/geocaching/DataStore.java
@@ -2334,23 +2334,21 @@ public class DataStore {
* @param geocodes
* @return
*/
- private static Set<String> exceptCachesWithOfflineLog(Set<String> geocodes) {
+ private static Set<String> exceptCachesWithOfflineLog(final Set<String> geocodes) {
if (geocodes.isEmpty()) {
return geocodes;
}
- init();
- final Cursor cursor = database.query(
- dbTableLogsOffline,
+ final List<String> geocodesWithOfflineLog = queryToColl(dbTableLogsOffline,
new String[] { "geocode" },
null,
null,
null,
null,
- null);
-
- final List<String> geocodesWithOfflineLog = Arrays.asList(getFirstColumn(cursor));
-
+ null,
+ null,
+ new LinkedList<String>(),
+ GET_STRING_0);
geocodes.removeAll(geocodesWithOfflineLog);
return geocodes;
}
@@ -2874,16 +2872,6 @@ public class DataStore {
});
}
- /**
- * Extract the first column of the cursor rows and close the cursor.
- *
- * @param cursor a database cursor
- * @return the first column of each row
- */
- private static String[] getFirstColumn(final Cursor cursor) {
- return cursorToColl(cursor, new LinkedList<String>(), GET_STRING_0).toArray(new String[cursor.getCount()]);
- }
-
public static void saveChangedCache(Geocache cache) {
DataStore.saveCache(cache, cache.getStorageLocation().contains(StorageLocation.DATABASE) ? LoadFlags.SAVE_ALL : EnumSet.of(SaveFlag.SAVE_CACHE));
}
@@ -3131,7 +3119,7 @@ public class DataStore {
+ " FROM " + table
+ " WHERE " + column + " LIKE ?"
+ " ORDER BY " + column + " COLLATE NOCASE ASC;", new String[] { getSuggestionArgument(input) });
- return getFirstColumn(cursor);
+ return cursorToColl(cursor, new LinkedList<String>(), GET_STRING_0).toArray(new String[cursor.getCount()]);
}
public static String[] getSuggestionsOwnerName(String input) {