diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-09-14 14:21:22 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-09-14 14:21:34 +0200 |
| commit | 947792ed914e4309ecb5159e9878ed15ea1125c9 (patch) | |
| tree | c62689ef2b6ffa7bb1568e9525ed2760e45aec9a /main/src/cgeo/geocaching/DataStore.java | |
| parent | 3d5d4c46327244244003982f71aa627d1407d5c3 (diff) | |
| download | cgeo-947792ed914e4309ecb5159e9878ed15ea1125c9.zip cgeo-947792ed914e4309ecb5159e9878ed15ea1125c9.tar.gz cgeo-947792ed914e4309ecb5159e9878ed15ea1125c9.tar.bz2 | |
refactoring: StoredList
* try more encapsulation instead of ID comparisons all time
Diffstat (limited to 'main/src/cgeo/geocaching/DataStore.java')
| -rw-r--r-- | main/src/cgeo/geocaching/DataStore.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java index f151ce3..507b042 100644 --- a/main/src/cgeo/geocaching/DataStore.java +++ b/main/src/cgeo/geocaching/DataStore.java @@ -13,6 +13,7 @@ import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.files.LocalStorage; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.list.AbstractList; import cgeo.geocaching.list.PseudoList; import cgeo.geocaching.list.StoredList; import cgeo.geocaching.settings.Settings; @@ -2021,7 +2022,7 @@ public class DataStore { reasonIndex = 1; } String listKey; - if (list == PseudoList.ALL_LIST_ID) { + if (list == PseudoList.ALL_LIST.id) { sql.append(" and reason > 0"); listKey = "all_list"; } else { @@ -2035,7 +2036,7 @@ public class DataStore { if (cacheType != CacheType.ALL) { compiledStmnt.bindString(1, cacheType.id); } - if (list != PseudoList.ALL_LIST_ID) { + if (list != PseudoList.ALL_LIST.id) { compiledStmnt.bindLong(reasonIndex, list); } return (int) compiledStmnt.simpleQueryForLong(); @@ -2078,7 +2079,7 @@ public class DataStore { final StringBuilder selection = new StringBuilder(); selection.append("reason "); - selection.append(listId != PseudoList.ALL_LIST_ID ? "=" + Math.max(listId, 1) : ">= " + StoredList.STANDARD_LIST_ID); + selection.append(listId != PseudoList.ALL_LIST.id ? "=" + Math.max(listId, 1) : ">= " + StoredList.STANDARD_LIST_ID); selection.append(" and detailed = 1 "); String[] selectionArgs = null; @@ -2539,8 +2540,8 @@ public class DataStore { } Resources res = CgeoApplication.getInstance().getResources(); - if (id == PseudoList.ALL_LIST_ID) { - return new StoredList(PseudoList.ALL_LIST_ID, res.getString(R.string.list_all_lists), getAllCachesCount()); + if (id == PseudoList.ALL_LIST.id) { + return new StoredList(PseudoList.ALL_LIST.id, res.getString(R.string.list_all_lists), getAllCachesCount()); } // fall back to standard list in case of invalid list id @@ -2655,7 +2656,11 @@ public class DataStore { } public static void moveToList(final List<Geocache> caches, final int listId) { - if (listId == PseudoList.ALL_LIST_ID) { + final AbstractList list = AbstractList.getListById(listId); + if (list == null) { + return; + } + if (!list.isConcrete()) { return; } if (caches.isEmpty()) { |
